Black_Trash
asked on
web service asmx to return json without "<string xmlns="http://tempuri.org/">" tacked on to
Built a web service and the output has "<string xmlns="http://tempuri.org/">" tagged on to the top of the output. Trying to read the output with jQuery and I think "<string xmlns="http://tempuri.org/">" causing the jQuery to have problems parsing the data.
The c# code in the web service is the following:
[WebMethod]
[ScriptMethod(ResponseForm at = ResponseFormat.Json)]
.......................... .......... .......... ........
da.Fill(ds, "Inventory");
sqlConnection1.Close();
XmlDataDocument doc = new XmlDataDocument(ds);
string jsonStr = JsonConvert.SerializeXmlNo de(doc);
// JavaScriptSerializer jsonstuff = new JavaScriptSerializer();
return jsonStr;
Sample of the string out:
<string xmlns="http://tempuri.org/">
{"NewDataSet":{"Inventory" :[{"MOVE_I D":"577"," FeedyardID ":"3","Lot ":"103","P en":"103 ","MoveDate":"2011-04-25T0 0:00:00-
What do I need to do to get rid of the <string xmlns="http://tempuri.org/"> or enable jQurey to parse the data into the correct fields?
Thanks,
Keith
The c# code in the web service is the following:
[WebMethod]
[ScriptMethod(ResponseForm
..........................
da.Fill(ds, "Inventory");
sqlConnection1.Close();
XmlDataDocument doc = new XmlDataDocument(ds);
string jsonStr = JsonConvert.SerializeXmlNo
// JavaScriptSerializer jsonstuff = new JavaScriptSerializer();
return jsonStr;
Sample of the string out:
<string xmlns="http://tempuri.org/">
{"NewDataSet":{"Inventory"
What do I need to do to get rid of the <string xmlns="http://tempuri.org/"> or enable jQurey to parse the data into the correct fields?
Thanks,
Keith
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome Keith, thanks for the points.
ASKER
After doing some digging around on my $.ajax and maybe the combination of adding
to the system.webServer section of the client program config.system system.webServer section:
<handlers>
<add name="ScriptHandlerFactory
verb="*" path="*.asmx"
type="System.Web.Script.Se
resourceType="Unspecified"
</handlers>
</system.webServer>
I was able to parse the JSON string and then break out the record fields.
var obj = $.parseJSON(Some_data);
alert("Parsed =" + obj.NewDataSet.Inventory[0
Just as a note I used the following for the AJAX call:
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: 'json',
url: MYurl,
data: "{}",
success:function (data) {
strData = data.d;
parseData(strData);
},
error: function (a) {
alert(a.responseText);
}
});
In the above is not perfect, still has some test items in it, but it works.
Thank you both for helping me out.
Thanks,
Keith Black