$(" # btn1 "). Click (function () {
Var jsonObj={" account ":" value1 ", "contant" : "value2" "Detail" : [{" product ":" value3 ", "model" : "value4", "QTY" : 1}]}
;
Var jsonStr=JSON. Stringify (jsonObj);
//alert (jsonStr);
$. Ajax ({
Type: "POST",
ContentType: "application/json; Charset=utf-8,
"Async: false,
DataType: "json",
Url: "http://localhost:8078/data.asmx/HelloWorld",
Data: jsonStr,
Success: the function (data) {
Alert (data. D);
},
Error: function (data) {
Alert ($. ParseJSON (data. The responseText). The Message). },
});
});
[the WebMethod]
Public string HelloWorld (string jsonStr)
{
Return "Hello" + jsonStr;
}
CodePudding user response:
JsonObj={" account ", "value1", "contant" :
"Detail" : [{" product ":" value3 ", "model" : "value4", "QTY" : 1}]}
The write wrong json format itself has a problem
CodePudding user response: