$.post( url : 'xxx', data : "{x:var1,y:var2}", function(msg){ alert(data); }, type:'json')
I pass parameters like the one written above to the Java backend, where var1,var2 is I use $ ("#xx"). Val () Gets the contents of the input space, which is successfully obtained in the front end, but the backend is not retrieved correctly (input space does not have a name attribute).
My question is: in this case of using $.post () without form and submit, does the Name property inside the input control have any effect on the data transfer?
Reply content:
$.post( url : 'xxx', data : "{x:var1,y:var2}", function(msg){ alert(data); }, type:'json')
I pass parameters like the one written above to the Java backend, where var1,var2 is I use $ ("#xx"). Val () Gets the contents of the input space, which is successfully obtained in the front end, but the backend is not retrieved correctly (input space does not have a name attribute).
My question is: in this case of using $.post () without form and submit, does the Name property inside the input control have any effect on the data transfer?
No impact, this is an AJAX POST request, the name and value of the data has been indicated in the database, the background to obtain the name and the name x y of the data can be obtained var1 and var2
It doesn't matter if you have a form or a submit, you can spell the right thing in data. There was a Formdata object in the XHR, and the new one came out and filled in the data and sent it out in the same way.
But is it okay if you write like that? The string I am generally similar to the ' key=value&key2=value2 ' this way of writing, or the use of JSON {' key1 ': ' value1 ', ' key2 ': ' value2 '} This kind of writing, relative will insure some ...