Reputation: 113
This is the file which sends ajax request.
function ju(id)
{
alert("into");
$.ajax({
type:'POST',
url: "trial2.php",
data: { flag1: id},
success: function(result) {
alert(result);
},
complete:function(){
alert("over");
}
});
}
ju("yoyo::");
</script>
the trial2.php is this. simply returning what ever it received.
session_start();
$resultstring = "yoyo :: " . $_POST['flag1'];
echo $resultstring;
?>
but only the "into" alert is coming. after this the page just stops working. no alerts nothing. whats wrong in this?? i have done a bit of ajax things in past, but never came accross this.
Upvotes: 0
Views: 60
Reputation: 808
You send an array to your php code as data , so you have to write
$data = $_POST['data'];
// $data is an array contain your flag1 .
Upvotes: 0
Reputation: 575
Maybe try adding an error callback to the ajax call to help narrow down the problem.
function ju(id)
{
console.debug("into");
$.ajax({
type:"POST",
url: "trial2.php",
data: { flag1: id},
success: function(result) {
console.debug(result);
},
complete:function(){
console.debug("over");
},
error: function(xhr, error){
console.debug(xhr);
console.debug(error);
}
});
}
Upvotes: 0