Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xmlhttp request and querystring parameters

Tags:

http

xml

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);

}

1 Answers

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);
like image 112
lonesomeday Avatar answered Jan 25 '26 22:01

lonesomeday



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!