user1994529
user1994529

Reputation: 157

change url ajax get request

i have an ajax call get

$.get('http://tvc.loc/search?searchData='+searchVal, function(returnData) {}

but have my base url stored in a variable

var url = (location.protocol + "//" + location.hostname + 
  (location.port && ":" + location.port) + "/");

but now i wan't to do something like this

$.get('"+url/search?searchData='+searchVal, function(returnData) {}

but i don't know if this is possible but i can't seem to get it working

Upvotes: 0

Views: 101

Answers (1)

techfoobar
techfoobar

Reputation: 66663

You can use + to concatenate:

$.get(url + '/search?searchData='+searchVal, function(returnData) {});

Upvotes: 3

Related Questions