0

Your help would be most appreciated. I'm dong this jquery ajax GET right. Although it submits and sends as a $_GET and is processed fine by process.php for some reason it is not reflected in the url.

jQuery('#results-submit').click(function() {
       
        jQuery('#waiting').show(0);
        jQuery('#container').hide(0);
        jQuery('div.carpark').remove();
       
        jQuery.ajax({
            type : 'GET',
            url : 'process.php',
            dataType : 'json',
            data: {
                airport : jQuery('#airport').val(),
                name : jQuery('#name').val(),
                email : jQuery('#email').val(),
                date : jQuery('#date').val(),
                add2 : jQuery('#add2').val()
            },
            success : function(data){

                jQuery('#container').show(0);
                jQuery('#container').removeClass().addClass((data.error === true) ? 'error' : 'success').replaceWith(data.result).show(500);
                if (data.error === true)
                    jQuery('#results_form').show(500);
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                jQuery('#waiting').hide(500);
                jQuery('#container').removeClass().addClass('error').text('Please fill out all the required fields.').show(500);
                jQuery('#results_form').show(500);
            }
        });
       
        return false;
    });
2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by hielo
0

...for some reason it is not reflected in the url

ajax requests do NOT change the url that is currently loaded/displayed in the address bar. The requests occurs "in the background". Hence the url in address bar remains unchanged. IF it did so, then the whole page/window would reload, which defeats the purpose of ajax.

0

Yeah so can i not show the URL in the address bar with the get request details? so i can link people directly to specific get requests?

Edited by lobas: n/a

0

Yeah so can i not show the URL in the address bar with the get request details?

I don't understand what you are asking. IF you arrive at page1.php and you need data/info from page2.php and you do NOT want page2.php in the address bar, then when you send the ajax request to page2.php, then the address bar will remain as page1.php. In other words, page2.php remains "hidden".

Now if you want to pass parameters to page2.php, then instead of arriving at page1.php, your users should be arriving to something SIMILAR to page1.php?section=comments then before you send the ajax request, retrieve the string after the quation mark from location.href:

var params = location.href.substring(location.href.indexOf('?') )

then on the server you should be able to see those parameters and send content specific for those parameters.

0

Hmmm it's basically a search form, so someone from another page enters details into a search box and it loads results.php instead of results.php I need to have say /results/somevalue/anothervalue/somemorevalues/1/2 etc... which I could then copy and paste to someone which would then load the same values

0

search for "url rewrite tutorial". Basically your server will "look" at the url first, and (as long as you provide the correct/necessary rewrite rule), internally it can/will send the request to results.php?params=somevalue anothervalue, etc.

If you are using an apache server, chances are you already have that capability. If you are not the webmaster/administrator of the server, contact the admin to find out if your server supports url rewrite.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.