Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    45
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Angry How do I access the header using AJAX?

    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:

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

    Apologies for not being very technical.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    You can access the URL of the current page and then use regular expressions to filter for the value of bar
    Code:
    var theMatch = location.href.match(/bar=(.*)&/);
    var theValue = '';
    if(theMatch) {
       theValue = theMatch[1];    // bar=xxxx is one of several parameters
    } else {
       theMatch = location.href.match(/bar=(.*)$/);
       if(theMatch) theValue = theMatch[1];     // bar=xxxx is the only parameter
    }
    ...
    xmlhttp.open("GET","new_film_pro.php?x="+theValue,true);


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •