current position:Home>The Ajax backend accepts post data and writes it directly to the database

The Ajax backend accepts post data and writes it directly to the database

2022-04-29 16:49:38CSDN Q & A

I follow the online tutorial On the front end script Use in $ajax And then use Post Request to send data But I tried many times Also tried for several days I never know how I can receive the data I sent And write it directly into the database
Here is my code
$.ajax({
type: 'post',
url: '/index/check.php',
data: {
'address': accounts[0]
},
dataType: 'text',
success: function (res) {
code = JSON.parse(res).data.code;
// alert( JSON.parse(res))
if (code) {
$('#mycode').text(code);
$('#up_code').hide();
$('#up_input').hide();
$('#qr1688').hide();
} else {
$('#mycode').hide();
}
},
Is there a brother Can you give me an answer Thank you very much I don't know if there is a problem with this code It is basically written according to the online tutorial Should be able to send normally POST data however After sending I don't know how to view the data I sent I don't know how to get this data from the background It should be said that I don't know how to write the background code that accepts data Do you have any answers The requirement is that it is best to write data directly




Take the answer :

1. Feeling datatype Should be JSON
2. The background receiving parameters can be used for trial Httpservletrequest Parameters , Or add @Requestbody Annotated JSONobject


copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/112/202204222353290812.html

Random recommended