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:
 
$.get("test.php",
   function(data){
     $('#fetch').html( "Name: " + data.name ); // John
     $('#fetch2').html( "Time: " + data.time ); //  2pm
   }, "json");

Open in new window


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...

Open in new window


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.
LVL 1
tjyoungAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
leakim971Connect With a Mentor PluritechnicianCommented:
$.get("test.php?account_id=<?php echo $account_id;?>&campaign_id=" + $("select[name='contests']").val(),
   function(data){
     $('#fetch').html( "Name: " + data.name ); // John
     $('#fetch2').html( "Time: " + data.time ); //  2pm
   }, "json");
0
 
tjyoungAuthor Commented:
Perfect. Many thanks.
0
All Courses

From novice to tech pro — start learning today.