0

Edit: Answer I was looking for is How can I get query string values in JavaScript?. I wasn't familiar with the term 'query string' so didn't have a good sense of what to look for.

I have a simple web application that takes search criteria in a web form and produces visualizations with data returned from a DB from those criteria. For the sake of this example, let's say the search form takes a searchString and a date, and returns some arbitrary array of data that is displayed in the UI.

I would like to add GET request handling such that, if given a get request such as:

http://myApp.com/?searchstring="MySearch"&date="1-1-1990"

I can use that input as if it was entered in the form and the "submit" button was clicked. However I am not sure how to build this functionality on the JavaScript end. My server already features a simple API which the JS frontend uses to communicate with a backend, however this only returns JSON which is interpreted by the UI.

Is there a simple way to create an event handler for GET requests and parse out the data contained? It seems similar to the API I use, but I am not sure how to run this on the client side or attach it to some sort of event handler.

Thanks

Community
  • 1
  • 1
UpQuark
  • 791
  • 1
  • 11
  • 35
  • 2
    http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript – Ejaz May 15 '14 at 18:46
  • Thanks. I wasn't sure what terms to look for, I guess 'query string' is what I wanted. Is the way to deal with event handling to check the query string on the onLoad event, and if it isn't empty, call my handler method? – UpQuark May 15 '14 at 18:48
  • 1
    yes, on page load just run the code and extract variables from query string. – Ejaz May 15 '14 at 18:53

0 Answers0