Sunday 8 September 2013

How to pass tag's id="" using ajax to an external php page?

How to pass tag's id="" using ajax to an external php page?

My first issue was getting the clicked element ID has been answered but
then I got the 2nd issue, POST the ID to the php page, im trying the
following code, in index.php
echo '<li ><a id="'.$rowmnu2['link'].'" href="#"
onclick="passto(this)">'.$rowmnu2['title'].'</a></li>';
and here is my ajax function : alert (val);
function passto(val){
$.ajax({
type: "POST",
url: "ProductsList.php",
data: {prodID:val},
dataType: "json",
complete:function(){
alert (val);
window.location("ProductsList.php")
}
});
}
the passed element to the function is an integer
in the ProductsList.php I have
<?php
$test = $_POST['prodID'];
echo $test;
?>
on the top of the page.
the problem is that the ProductsList.php wont be loaded, is like nothing
is happening, except the alert. what am I doing wrong here? help me out
here please.

No comments:

Post a Comment