elbatron
elbatron

Reputation: 705

Data variable in jquery ajax function

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.

Upvotes: 2

Views: 5029

Answers (1)

Saigework
Saigework

Reputation: 111

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

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

Upvotes: 3

Related Questions