How to solve the error problem of sending JSON data to the background by Ajax
How to solve the error problem when Ajax sends JSON data to the background, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
The code is as follows:
$.ajax ({
Url: ".. / Services.ashx"
Type: "POST"
/ / data: {'data': {' typename': JSON.stringify (typename)}, 'operationType':' 2'}
Data: {'data': typename,' operationType':'2 recording recording no _ wheightball _ now _ area}
Success: function (msg) {}
})
As shown in the js code above, when the value of the key-value pair in data is null (undefined), the key-value pair with the value of null will not be passed to the background when sending the request.
1. Through F12, you can see that the key-value pair with the value of null is not passed.
2. When using context.Request.Form ["name"] in the background, it is found that this value is null, and an error will be reported if you get it.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.