SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    seattle
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    trying to get query string to display in address bar

    hi,

    i'm using ajax and in my form i have th method get, but my query string isn't showing on my address bar. This is the first time using ajax. can someone help me with the code below?

    Code:
    function getstores(city, state){
    var xmlhttp=false; 
            try {
                    xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); 
    
            } catch (e) {
                    try {
                            xmlhttp = new
                            ActiveXObject('Microsoft.XMLHTTP'); 
                } catch (E) {
                    xmlhttp = false;
                            }
            }
            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                    xmlhttp = new XMLHttpRequest(); 
            }
         
    	 xmlhttp.open('GET', 'getstores.php?state=' + state + '&city=' + city, true); 
        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState==4) { 
                    var content = xmlhttp.responseText; 
                    if( content ){ 
                          document.getElementById('stores').innerHTML = content; 
                    }
            }
            }
            xmlhttp.send(null) 
    return;

  2. #2
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wakk0 View Post
    hi,

    i'm using ajax and in my form i have th method get, but my query string isn't showing on my address bar. This is the first time using ajax. can someone help me with the code below?

    Code:
    function getstores(city, state){
    var xmlhttp=false; 
            try {
                    xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); 
    
            } catch (e) {
                    try {
                            xmlhttp = new
                            ActiveXObject('Microsoft.XMLHTTP'); 
                } catch (E) {
                    xmlhttp = false;
                            }
            }
            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                    xmlhttp = new XMLHttpRequest(); 
            }
         
    	 xmlhttp.open('GET', 'getstores.php?state=' + state + '&city=' + city, true); 
        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState==4) { 
                    var content = xmlhttp.responseText; 
                    if( content ){ 
                          document.getElementById('stores').innerHTML = content; 
                    }
            }
            }
            xmlhttp.send(null) 
    return;
    I didn't understand why you want those parameter in address bar BUT here is something i know and would like to share it with you...

    Ajax calls are mostly in background .The parameters which you will pass won't be displayed in address bar of your site instead a get request will be made to server without any refreshing of your page.

    But if you want to track what parameters are been sended to server you can use add-on of firefox "firebug" which will show you what parameter is been sent.

    Hope it help.

    Thanks.


Bookmarks

Posting Permissions

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