开发者

jquery return from post

开发者 https://www.devze.com 2023-02-07 23:31 出处:网络
i have jQuery script: var order = \'user=lolalola\'; $.post(\"ajax.php\",{action:\"run\"}, order, function(data){

i have jQuery script:

var order = 'user=lolalola';
$.post("ajax.php",{action:"run"}, order, function(data){
     alert("Data Loaded: " + data);
     $("#dd_message").html(data);
});

and php scitp:

<开发者_StackOverflow中文版;?php
echo 'php file';
print_r($_POST);
?>

Why jquery no run php script? Return full php code:

<?php
    echo 'php file';
    print_r($_POST);
    ?>


What is order param? Callback should go as third parameter: look at documentation. Unless order is the name of function defined elsewhere.


you have an extra parameter there. You should be getting a JS error on the browser. try this:

var order = 'user=lolalola';
$.post("ajax.php",{action:"run", user:"lolalola"}, function(data){
     alert("Data Loaded: " + data);
     $("#dd_message").html(data);
});


All the POST fields should be in 1 parameter.

var order = 'user=lolalola';
$.post("ajax.php",'action=run&'+order, function(data){
     alert("Data Loaded: " + data);
     $("#dd_message").html(data);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消