To send json to the server, you first have to create json
function sendData() {
$.ajax({
url: '/helloworld',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
name:"Bob",
...
}),
dataType: 'json'
});
}
This is how you would structure the ajax request to send the json as a post var.
function sendData() {
$.ajax({
url: '/helloworld',
type: 'POST',
data: { json: JSON.stringify({
name:"Bob",
...
})},
dataType: 'json'
});
}
The json will now be in the json
post var.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…