2

Yesterday I had question (answered), which I have to expand a bit more today. I need to pass two or more variables, but I can't find the proper syntax: UPDATED, WORKING CODE:

$(document).ready(function() { 
   $('.infor').click(function () {

    var datasend = $(this).html();
    var datasendmore = $(this).next().html();

      $.ajax({
           type: 'POST',
           url: 'http://domain.com/page.php',
           data: {im_id:datasend, yt_id:datasendmore},
           success: function(data){
              $('#test_holder').html(data);
              }
           });
    }); 
});

Thanks.

2
  • 1
    Does .next work in this way or is it .next() that you need? Commented Nov 6, 2011 at 9:42
  • Right, updated above the snippet again. Commented Nov 7, 2011 at 16:26

2 Answers 2

3

use:

data: {im_id:datasend,yt_id:datasendmore}
Sign up to request clarification or add additional context in comments.

1 Comment

That was quick. I updated my question with the correct syntax.
1

There is one minor typo:

data: 'im_id='+datasend','

should be

data: 'im_id='+datasend+',

From what I can see above.

and I'd use {im_id: value1, param2:value2, param3:value3 etc}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.