Hi all,
I'm not too familiar with Ajax but I believe I grasp the basics. So I'm sending an id which I retrieve from an element to a php page but I can't seem to retrieve the id being send.
My javascript:
function ListPart(part) {
var imgdata = part;
$.ajax({
url: "components.php",
type: "POST",
data: { id : imgdata },
dataType: "text",
success: function(imgdata) {
alert(imgdata);
}
});
return false;
}
My components.php:
<?php
if(isset($_POST["id"])) {
echo $_POST["id"];
} else {
echo "not found";
}
?>
Am I missing something small? Also I would like to know in that alert(imgdata) I get the whole document's html and not just the id? Is there a reason for this?
PS: The "not found" is not even being displayed. Although the alert in the success function does execute.
Any help will be appreciated!
Thanks.