I try to post an JS object to PHP, but the PHP says nothing.. It looks like it don't recognize the POST...
Here is the JS :
$('.send').click(function() {
var Scommand = JSON.stringify(command);// Command is my JS obj
if (commande.type) {
$.ajax({
url:'test.php',
context:$(this),
type:'POST',
data:Scommande,
success : function(data){
commande = {};
window.location='test.php';
}
});//End Ajax
}
else {'PLz specify a type');}
});
And my PHP :
It returns : Notice: Undefined index: type in /Applications/MAMP/htdocs/BackOfficeDavid/test.php on line 2
Like nothing go throw the POST ... Any clue ? data:{mydata: Scommand}, and look at $_POST['mydata']
以上就是POST a javascript objet to a PHP file的详细内容,更多请关注web前端其它相关文章!