URL not showing request parameters

2.8k Views Asked by At

I am taking some data from user-2 paramerters(using JS,html,jquery) , when user pclicks on GO, then calling servlet, passing these two parameters in get request:

$.get("/Myservlet?param1="+myval+"&region="+myregion,function(data){addToTables(data);hideLoading();},"text");

Servlet is returning data for these 2 parametrs, and i am showing that as tables in browser. But the prob is ,the browser URL is not changing , suppose it was abc.com earlier and it displays data for the 2 parameters it is still abc.com

why doesnt it change to abc.com?param1=myval&region=myregion

Why URL doesnt show the query string ?

3

There are 3 best solutions below

0
On

Your code is really hard readable. It seems for me you did misunderstand $.get. Thsi Command does not change the browser url. It sends a get request. You can see the in Firebug tab Network.

Then you need a success function which is executed then the request was successfull.

By the way: GET is insecure (or at leat easier to change), use POST instead.

0
On

You are making an AJAX request, which doesn't change the URL. You can change it manually using HTML5's History changeState if the browser in which you are running your script supports it.

0
On

The browser url is not going change, based on your code. The url is fixed as soon as the web page this code is on loads (though you might be able to change it using the technique JM Perez suggests).

Your code performs an asynchronous GET request to the url you have specified. The entire page is not reloaded and the browser url does not change.

You might want to read up about ajax here. The type of url you want can be achieved as a result of a form submission.