なぜか質問を投稿すると反映されない。。 何かしら問題があってはじかれている??
Ajaxでオブジェクトを送信する時の注意点
It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).
contentTypeは’application/json’にする。
dataの値は、JSON文字列にする
誤
$.ajax({
url : 'check.php'
,type : 'post'
,dataType : 'json'
,data : {'foo':'bar', 'span':'piyo'}
,processData : false
,contentType : false
})done(function(response, textStatus, xhr){
console.log(response);
})fail(function(xhr, textStatus, errorThrown){
console.log('fail');
});
正
$.ajax({
url : 'check.php'
,type : 'post'
,dataType : 'json'
,data : {'foo':'bar', 'span':'piyo'}
})done(function(response, textStatus, xhr){
console.log(response);
})fail(function(xhr, textStatus, errorThrown){
console.log('fail');
});
検索

コメントを残す