View Full Version : urgent help

03-15-2012, 01:32 PM
can any one please help me out with the code.

I am passing an URL for ex: www.example.com?req=23&param=25

What i need to do is I need to remove the parameters after "?" which I did using the spilt method,

Can anyone help me out now how do I send the complete URL with the parameters as hidden.

what I mean is..my URL should look like

but the second part (parameter shud be hidden).

03-15-2012, 01:46 PM
You mean hidden but still effective?

You cannot do that with Javascript. As soon as you change the URL of the current page (including the removal of parameters), the page will refresh by re-requesting it from the server. The server will most certainly "miss" the parameters and will then not generate the appropriate page.

One question: How did the parameters get there? Did they come from a previous page that sent some form data to the server using the GET method? If yes, you can switch the form method to POST (which will still send the data, but not in the URL any more). This also means that you need to change the server side script to accept POST parameters instead of GET.

03-15-2012, 05:22 PM
No I am using the Post method, this URL is getting formed using few components.
I can provide you with the code snippet which I am using, if you can help thereafter.

function subLink(param){
hiddenVal = document.getElementById('GENENUM').value;

if(param!= ""){

var form = document.createElement("form");

var hiddenObj = document.createElement("input");
hiddenObj.type = "hidden";
hiddenObj.id = "some id";//same which is used in form
hiddenObj.name = "some_token";
hiddenObj.value = hiddenVal;
var myString = new String(document.location);
var myArray = myString.split('?');





03-15-2012, 05:34 PM
continuing with your logic...

var myArray = myString.split('?');

var myRealArray = myArray[1].split('&');

var myTokens = {};

for (var i=0 ; i<myRealArray.length ; ++i){

var tmp = myRealArray[i].split('=');

myTokens[tmp[0]] = tmp[1];

//now you have a myTokens object equal to {"req":"23" , "param":"25"}

Huh, I did not read that question right... but if you wish to conceal your parameters, you should just use AJAX to post your form. sorry for the confusion

03-15-2012, 09:36 PM
Thanks for the reply mate..

But I need to do this with a javascript only. It is basically a URL rewriting, cant I do with making the extracted param as hidden.

I am sorry I am newbie to Js... n dont have much command over it.

I dont want to use anything other than JS, cant we make the parameters after ? as hidden ...and pass the same.

03-15-2012, 09:44 PM
AJAX is javascript

03-15-2012, 09:49 PM
AJAX is javascript

:( :(

Can u help me out with code...how can I do that?

03-16-2012, 04:12 AM
Has anybody any solution to this?

03-16-2012, 03:40 PM
Simple AJAX request

function createRequest() {
try {
request = new XMLHttpRequest();
} catch (tryMS) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (otherMS) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
return request;

function getStreets(city){

var streets = document.getElementById("streets");
var ctid = document.getElementById("ctid").value;

streetRequest = createRequest();
if (streetRequest == null)
alert("Unable to create request");
else {

var url= "/dripdrop/includes/myincludes/getStreets.php?city=" + city.value + "&ctid=" + ctid;
streetRequest.onreadystatechange = function(){
if (streetRequest.readyState == 4)
if (streetRequest.status == 200) {

streets.innerHTML = streetRequest.responseText;

streetRequest.open("GET", url, true);

in this example streetRequest.responseText is what is being returned from the server.