我正在通过一个看起来像的 ajax 调用来调用 Web 服务 -
$.ajax({
cache: false,
type: 'POST',
url: 'renderDisplay.asmx/displayElements',
dataType: 'json',
data: object,
success: function () {
alert ("success"); },
error: function (response) {
alert("error: " + response.responseText);}
});
我的网络服务功能 -
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, string> temp = new Dictionary<string, string>();
temp.Add("boston", "mass");
string json = serializer.Serialize((object)temp);
return json;
我得到的错误 -
注意:左括号“<”已放在括号中,否则两行将被视为实际代码
error: (<)?xml version="1.0" encoding="utf-8"?>
(<)string xmlns="http://tempuri.org/">{"boston":"mass"}</string>