通过dojo.xhrPost访问web服务,请求返回的格式为Json ,通过dojo.fromJson 将字符串生成Json对象
var intakenameselected=this.widgets.intakname.value; var xhrArgs = { url: "services/WebService.asmx/GetWaterIntake",handleAs: "json",headers: { "Content-Type": "application/json" },postData: '{"name":"' + intakenameselected + '"}',load: function (data) { // alert(data.d); var myData=dojo.fromJson(data.d); dijit.byId("intaketxtName").setValue(myData[0].Name); dijit.byId("intaketxtNum").setValue(myData[0].Serialnumber); dijit.byId("intaketxtriver").setValue(myData[0].Riverin); dijit.byId("intaketxtwater").setValue(myData[0].Takewater); },error: function (error) { alert(error.toString()); } }; dojo.xhrPost(xhrArgs);原文链接:https://www.f2er.com/dojo/291585.html