Closed losnau closed 6 years ago
Looks like server side issue.
@tkirda Firstly ,I sorry to say my english is bad . = = ....! Secondly,Thanks you reply.
I set 'Content-Type': 'Content-Type:text/plain;;charset=utf-8' , Server get request , The data is "search=true&keyword=1234", Why not JSON?
And I see from chrome begug , In Reuest Payload This is "search=true&keyword=1234" Why no JSON?
Try adding method POST to ajaxSettings:
ajaxSettings: {
method: 'POST'
// ...
}
Just no work,
serviceUrl: '/cmd/get',
width: 200,
scrollHeight: 300,
matchContains: true,
autoFill: false,
deferRequestBy:50,
paramName:'keyword',
// noCache:true,
// dataType: 'json',
// type:"POST",
// params: {"search":true},
ajaxSettings:{
headers: {
// method: 'POST' ,
// 'Content-Type': 'Content-Type:text/plain;;charset=utf-8'
// "Content-Type":"application/json",
data: '{"search":true,"q":"frfsdafi"}',
type: 'post',
dataType: 'json',
method: 'POST' ,
"Content-Type": 'application/json;charset=utf-8',
async:false
}},
And I find if the Reuqst Headers‘ Content-Type: is "application/x-www-form-urlencoded; charset=UTF-8" ,Server get None。 And In other ways ,If the Reuqst Headers‘ Content-Type: is "application/json;charset=UTF-8" ,Server get data 。
However,Whatever I do In ajaxSettings , the Reuqst Headers‘ Content-Type: is "application/x-www-form-urlencoded; charset=UTF-8"......
It is Crazy...
I had a similar problem and was able to overcome it by using the the ajaxSettings parameter.
All calls to our webservice required the data param in the ajax settings to be json serialized.
This worked for me:
ajaxSettings: {
type: "POST",
processData: false,
contentType: "application/json; charset=utf-8",
beforeSend: function (jqXHR, settings)
{
settings.data = JSON.stringify(settings.data);
}
}
autocomplete Ajax config: serviceUrl: 'http://localhost:8889/cmd/get', width: 200, scrollHeight: 300,
matchContains: true,
autoFill: false,
deferRequestBy:50, paramName:'keyword',
noCache:true,
dataType: 'json', type:"POST",
params: "search",
ajaxSettings:{"contentType": 'application/json;charset=utf-8'}
However ,The server response status is 400,
In test file ,I config config ajax is that
The server reponse status is 200,And I get those data.