When using Ajax to pass data, it is possible to pass multiple data, which can be used to pass data in such a way that the data is too large and mixed
$.ajax ({ type:' post ', url:url, data:{data:data, Content1:content1, Content2:content2,content3:content3,...........}, success:function (data) { alert (data) } });
We can then wrap the data in the array before passing the data, but be aware that when defining an array, use the arr={} form
var arr= {}; var text= '; arr[' Content1 ']= ' value 1 '; arr[' Content2 ']= ' value 2 '; arr[' Content3 ']= ' value 3 '; arr[' Content4 ']= ' value 4 '; $.ajax ({type:' Post ', Url:url, Data:arr, async: false,//set to synchronous operation to assign a value to a global variable successfullySuccessfunction(data) {
Text=data; } });
Alert (text)
The async:false in the code above is to set the Ajax pass default asynchronous operation to synchronous operation, so that the returned value can be assigned to text, run when the popup will output the returned content, if there is no async:false
, the popup is empty
Small note (i): Ajax passes an array and assigns the Ajax return data