On the displayed page, use ajax to post the value. The value data is in json format. Received in the controller, but only received the part score. There is a url in the uploaded value data. The url contains the special symbol & amp;. The received value is the symbol, and the following is missing. For example, data in source code...
On the displayed page, use ajax to post the value. The value data is in json format. Received in the controller, but only received the part score. There is a url in the transmitted value data. The url contains a special symbol &, And the received value is the symbol, which is missing. For example, the data in the source code is the value I want.
Reply content:
On the displayed page, use ajax to post the value. The value data is in json format. Received in the controller, but only received the part score. There is a url in the transmitted value data. The url contains a special symbol &, And the received value is the symbol, which is missing. For example, the data in the source code is the value I want.
Depends on the type you pass to data:
- If it is an object, jquery will automatically add encodeURIComponent when sending the ajax request, and the & symbol is encoded as % 26, not automatically truncated by formData
- If data is a string, jquery automatically places the string in formData and sends it to the server. Because formData is passed and truncated, the string is automatically truncated without passing through encodeURIComponent.
Before submission, URL Encode the url you uploaded
The value corresponding to data is encapsulated in JSON. stringify ({}).
For example:
$ (". A_post "). on ("click", function (event) {event. preventDefault (); // invalidate the method that comes with a $. ajax ({type: "POST", url: "url address", contentType: "application/json", data: JSON. stringify ({param1: "param1", param2: "param2", url: "http: // xxxx? A = a & B = B & c = c ", param3:" param3 "}), // dataType:" json ", success: function (result) {// actions after the request is correct}, error: function (result) {// actions after the request fails }});});
View the request parameters as follows:
Use this JSON. stringify ({}) is encapsulated, that is, a problem occurs when ajax is passed. data: 'Data = '+ data is used, so there is a problem with passing the value, but data: {data: data}. That's all. Why?