2

I'm trying to use the code below, but it's not working: UPDATED WORKING:

$(document).ready(function() { $('.infor').click(function () { var datasend = $(this).html(); $.ajax({ type: 'POST', url: 'http://domain.com/page.php', data: 'im_id='+datasend', success: function(data){ $('#test_holder').html(data); } }); }); }); 

As you can see I used $datasend as the var to send but it doesn't return the value of it, only its name.

1 Answer 1

3

I would change $datasend = $(this).html; to var datasend = $(this).html();

Next I would change data: 'im_id=$datasend', to data: 'im_id='+datasend,

Sign up to request clarification or add additional context in comments.

2 Comments

How could I pass another variable in the data line? Fox example something like this: 'im_id='+datasend&'ot_id='+data2send
All you have to do is concatenate them (if you want to use that route) together. There are some quote problems with your code block above. 'im_id='+datasend+'&ot_id='+data2send In the long run you may want to assign all of this data to an array and then POST the array rather than build a giant string.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.