I am using Ben Alman’s jQuery BBQ to get the current page Querystring and Hash Values and storing them in a Javascript object using the following code:
var params = $.deparam.querystring();
var paramsHash = $.deparam.fragment();
These are all being set correctly; if I console.log them I get the returned values:
distance "0.1"
floorFrom "0"
floorTo "1000"
floorUnit "1"
ipp "10"
locationName "London"
location_val "LK||001"
tab "3"
Now what I want to do is pass these values to a page using a jQuery .load call.
At the moment I am using the code below
$('#result').load('mypage.php', { querystringData : params, hashData : paramsHash }, function()
{
...
}
Obviously though this is passing the data to mypage.php as: querystringData[locationName]=London
I need it to be passed through as locationName=London etc but unsure the best way to achieve this.
Update, adding clarification, copy of comment made on answer below
The thing I want to move away from is using querystringData and hashData in the .load call. If I was to write it all out it would look something like:
$('#result').load('mypage.php', { distance : '0.1', floorFrom: '0', floorTo : '1000', floorUnit : '1', ipp : '10', locationName : 'London', location_val : 'LK||001', tab : '3' }
I don’t know how to get the values out the object and display them in the .load call like that. The other problem is that I will add and remove querystring values so I don’t think it is something I can hardcode.
This is untested, but I think it should work, with my limited knowledge of BBQ:
I believe
paramsandparamsHashare already in the proper format, they just need to be merged. This may not be true for hash as I’m not familiar with BBQ.http://api.jquery.com/jQuery.extend/