Reputation: 290
Can I update the below jQuery code with the current url parameter? The parameters are changed each time.
$("#hotel-list").load("Rezults2.php?id=value&id2=value2 #hotel-list> *");
where this values are changed each time ?id=value&id2=value2
As example:
On the page 1 - Main Page where I have the below code, the url param is :
?DesinationId=BO9B&roomsno=1&city=Barcelona&In=2015-05-01&Out=2015-05-08&rooms%5B0%5D%5Badult%5D=2&rooms%5B0%5D%5Bchild%5D=0
I need to send the same param to Rezults2 page when I try to pull its data.
The name id`s from the URL are always the same but their values are changed each time.
Upvotes: 0
Views: 139
Reputation: 74738
So your question:
Can I update the below jQuery code with the current url parameter?
So I guess you want to get the location's search.
Try this:
var datastring = window.location.search; // now you can update this var and use
$("#hotel-list").load("Rezults2.php"+ datastring + " #hotel-list> *");
Maybe you want to use and append a var then:
var datastring = "?id=value&id2=value2"; // now you can update this var and use
$("#hotel-list").load("Rezults2.php"+ datastring + " #hotel-list> *");
If you go to the documentation of .load()
then you can find this:
.load( url [, data ] [, complete ] )
You can see that you can send data object too. So even you can try sending like this too:
var datastring = {id : value, id2 : value2}; // now you can update this var and use
$("#hotel-list").load("Rezults2.php #hotel-list> *", datastring);
Upvotes: 2
Reputation: 27614
Pass parameter of data to the server,
$("#hotel-list").load("Rezults2.php #hotel-list > *", { "id": value, "id2": value });
View this $.load() doc
You can also do something like this,
var data = "?id=" + value + "&id2=" + value2;
var url = "Rezults2.php?" + data + " #hotel-list > *";
$("#hotel-list").load(url);
Upvotes: 1