[solved] Something Wrong with postJSON


#1

I use postJSON to get server json data, but the data in request header with stringify.

var formData = app.form.convertToData(’#loginForm’);
app.request.postJSON("./login.json", formData, function(data) {
if (data.status) {
// Close login screen
app.loginScreen.close(’.login-screen’);
app.router.navigate("/tasklist");
} else {
app.dialog.alert(data.errorMsg, “error”);
}
app.preloader.hide();
}, function (data) {
app.preloader.hide();
})

but when i use post ,the request header of data is form data like this

var formData = app.form.convertToData(’#loginForm’);
app.request.post("./login.json", formData, function(data) {
if (data.status) {
// Close login screen
app.loginScreen.close(’.login-screen’);
app.router.navigate("/tasklist");
} else {
app.dialog.alert(data.errorMsg, “error”);
}
app.preloader.hide();
}, function (data) {
app.preloader.hide();
})

Here is the difference between two requests
image


#2

everything is ok

the “data” of the others (json,get,post)
are converted to a query string
unless processData is false

postJSON means => send-JSON-data
you send an obj/json
not a string

docs:

.get      => Load data from the server using a HTTP GET request
.post     => Load data from the server using a HTTP POST request
.json     => Load JSON-encoded data from the server using a GET HTTP request
.postJSON => Send JSON data using a HTTP POST request

#3

OK, thank you!
I had some misunderstandings about the postJSON before.