次のような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);}
});
My Web サービス機能 -
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, string> temp = new Dictionary<string, string>();
temp.Add("boston", "mass");
string json = serializer.Serialize((object)temp);
return json;
私が得るエラー -
注: 左角括弧 "<" は括弧で囲まれています。それ以外の場合は 2 行が実際のコードと見なされるためです。
error: (<)?xml version="1.0" encoding="utf-8"?>
(<)string xmlns="http://tempuri.org/">{"boston":"mass"}</string>