0

Say for example I had had page with the url of:

foo.php?bar='blob'

Is it possible to get the value of blob?

For example:

xmlhttp.open("GET","new_film_pro.php?x="+blob,true);

Thanks

Sheldon
  • 9,639
  • 20
  • 59
  • 96

4 Answers4

0

You can use this function: http://www.netlobo.com/url_query_string_javascript.html

Tobias
  • 7,238
  • 10
  • 46
  • 77
0

If you are using jsp then

var blob="<%request.getParameter('bar')%>";
xmlhttp.open("GET","new_film_pro.php?x="+blob,true);
Anupam
  • 7,966
  • 3
  • 41
  • 63
0

You should already know the value, if your xmlhttp call includes it, just parse the string

EDIT

function getArgs(url) {
    var args = new Object();
    var query = url.split("?")[1];
    var pairs = query.split("&");
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');
        if (pos == -1) continue;
        var argname = pairs[i].substring(0, pos);
        var value = pairs[i].substring(pos + 1);
        args[argname] = unescape(value);
    }
    return args;
}
var args = getArgs("testing.php?foo=bar");
txtValue.value = args.foo;
Kenneth Jakobsen
  • 458
  • 3
  • 11
0

See Pull variable from Query String and add into JS redirect URL

Community
  • 1
  • 1
Town
  • 14,706
  • 3
  • 48
  • 72