lolalola
lolalola

Reputation: 3823

jquery return from post

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:

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

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

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

Upvotes: 0

Views: 111

Answers (3)

gen_Eric
gen_Eric

Reputation: 227220

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);
});

Upvotes: 0

Victor
Victor

Reputation: 4721

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);
});

Upvotes: 0

Radek
Radek

Reputation: 8376

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

Upvotes: 1

Related Questions