javascript - consuming json with jquery ? .getJSON callback does not fire -
i've got cs webservice returns json when passed id: "jdoe"
<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">[{"department":"sales","mail":"jdoe@acme.com"}]</string>
i'm looking minimal jquery code display department , trying this:
$(document).ready(function () { url = "http://test.mydomain.com/webservice.asmx/getdept?callback=?" alert("start"); $.getjson( url, { id: "jdoe" }, function( data ) { alert(data.department); }); alert("end"); });
i see alerts start , end.
i've checked fiddler , not see errors call made.
on local webserver prompted id , return expected json.
my cs looks this:
public string getdept(string id) { var json = ""; var umid = result in dc.get_dept(id) select result; javascriptserializer jss = new javascriptserializer(); json = jss.serialize(id); return json;
the problem that
<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">[{"department":"sales","mail":"jdoe@acme.com"}]</string>
is xml json string inside. code work, need pass back:
[{"department":"sales","mail":"jdoe@acme.com"}]
on own.
Comments
Post a Comment