user520351
user520351

Reputation:

xmlhttp request and querystring parameters

I want to create a bookmark where it will send a parameter from the querystring such as author=John smith which would then be inserted into my rails app, is what I have so far correct? Providing I find out how to get the URL parameters

function updateData(param) {
  var myurl = 'http://localhost:3000/app/book';

  http.open("GET", myurl + "?author=" + value-of-querystring-param, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);

}

Upvotes: 3

Views: 2863

Answers (1)

lonesomeday
lonesomeday

Reputation: 237855

That looks like it should work, presuming that useHttpResponse is a handler function.

One thing that you probably should do is encode your parameter:

http.open("GET", myurl + "?author=" + encodeURIComponent(param), true);

Upvotes: 3

Related Questions