tjyoung
asked on
Trying to construct a URL using .get and can't get the syntax correct
Hi,
I'm trying to attache a couple different variables to a url using the code below (just a test url) and I can't figure out how to get it correct?
Here is what I have:
That works fine. What I'm trying to append on the url is 2 variables. One is a php variable and the other is from a select value using javascript. I can get the 2 variables fine, just don't know the proper way to string it on to the url.
Here is my guess (which doesn't work but might give you an idea what I'm trying to do)
Any help would be appreciated. Like I said I can get the variables, just don't know how to attach to the url without errors.
I'm trying to attache a couple different variables to a url using the code below (just a test url) and I can't figure out how to get it correct?
Here is what I have:
$.get("test.php",
function(data){
$('#fetch').html( "Name: " + data.name ); // John
$('#fetch2').html( "Time: " + data.time ); // 2pm
}, "json");
That works fine. What I'm trying to append on the url is 2 variables. One is a php variable and the other is from a select value using javascript. I can get the 2 variables fine, just don't know the proper way to string it on to the url.
Here is my guess (which doesn't work but might give you an idea what I'm trying to do)
$.get("test.php?account_id=<?php echo $account_id;?>&campaign_id=$("select[name='contests']").val()},
and so on...
Any help would be appreciated. Like I said I can get the variables, just don't know how to attach to the url without errors.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER