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;
            url: "components.php",
            type: "POST",
            data: { id : imgdata },
            dataType: "text",
            success: function(imgdata) {
        return false;

My components.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!


your data should be an array

data : [["id", imgdata], ["var2", val2]]

Still the same 'error' occurs...

What is part ? is it a string of html or a numeric ?

Part is an id which is received from the image.

This type of id?

<img id="457" src="image.png">

Yes exactly like that! Can this produce problems?


Sorry for the delay in replying. Can you describe in a non-technical way what it is that you are wanting to achieve?

can you dump your $_POST

also whats your js for grabbing the id in the first place