Reputation: 157
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
Reputation: 66663
You can use +
to concatenate:
$.get(url + '/search?searchData='+searchVal, function(returnData) {});
Upvotes: 3