Satch3000
Satch3000

Reputation: 49364

Javascript Passing variable not working in Ajax

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?

Upvotes: 1

Views: 95

Answers (1)

Chetan Bhopal
Chetan Bhopal

Reputation: 442

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

Upvotes: 3

Related Questions