0

I need a div to load certain content from another page (using ajax) into a div of a webapge(html) particular interval of time. this webpage have some query parameter in the url say, http:/www.test.com/new?startdate=2014-07-01&enddate=2014-07-23 Is it possible to get the prameters from the current url (including '?' i.e., ?startdate=2014-07-01&enddate=2014-07-23 ) and append it into ajax url.

Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130
user3217945
  • 23
  • 1
  • 5

2 Answers2

0

I think this would let you achieve that:

var url = window.location.href;
var q = url.substr(url.indexOf('?'));
alert(q); // alerts -> ?startdate=2014-07-01&enddate=2014-07-23
Jai
  • 74,255
  • 12
  • 74
  • 103
0

To get your parameters use

var startdate = getUrlParam('startdate'); 

and

var enddate = getUrlParam('enddate');

To prepend the '?' just do

var startdate = "?"+getUrlParam('startdate'); 
GCallie
  • 413
  • 1
  • 3
  • 11
  • @user3217945 No probs. If this helped you check it as the answer so other people who find this post and have the same problem will know that this is the solution :) – GCallie Jul 23 '14 at 12:09