1

I am having a problem passing a variable to my ajax where:

This will work: url: 'testing.php?id=1',

and this will not work: url: 'testing.php?id=theid',

Here is the full code which works:

function myfunc(theid) {
    $.ajax({
        url: 'testing.php?user_id=1',
        success: function() {
            alert('this worked' + venueid);
        }
    });
}

And this code does not pass the variable value:

function myfunc(theid) {
    $.ajax({
        url: 'testing.php?user_id=theid',
        success: function() {
            alert('this worked' + venueid);
        }
    });
}

Is this a syntax issue? What I'm I doing wrong here?

1
  • url : 'testing.php?user_id=' + theid Commented Jun 3, 2013 at 11:09

1 Answer 1

3
function myfunc(theid) {
$.ajax({
   url: 'testing.php?user_id='+ theid,
   success: function(){
   alert('this worked' + venueid);
                    }
});
}
Sign up to request clarification or add additional context in comments.

1 Comment

Be sure to declare theid too :)

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.