Bonjour a tous,
Je cherche simplement a envoyer un formulaire a l'aide d'une requête Ajax. J envoies mes infos en Json ce qui me donne le code suivant :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| $.ajax({
url: '',
type: 'POST',
data: JSON.stringify({ country : jcountry, region : jregion, from : jfrom, to : jto, currency : jcurrency }),
dataType: 'json',
success: function() {
alert("success")
$.mobile.changePage("menu1.html");
},
error: function (xhr, ajaxOptions, thrownError) {
alert( "Error: " + xhr.status + "\n" +
"Message: " + xhr.statusText + "\n" +
"Response: " + xhr.responseText + "\n" + thrownError);
$.mobile.changePage("menue2.html");
}
}); |
L'URL étant factice j'obtiens une erreur d'accord.
Mais avec firebug, dans mon header j'obtiens :
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Pourtant la source du POST est de ce type :
Source
{"country":"fhfh","region":"hfgh","from":"04/04/2013","to":"04/18/2013","currency":"fgh"}
Si j'ajoute dans mon code
contentType: 'application/json',
Je ne visualise plus le POST avec Firebug .. 
Quelqu'un peut il m’éclairer ? Merci a tous
Partager