title: How to access the URL of a GET AJAX request?
body: <p>I had a look at some other questions but I'm still not sure how to achieve this.</p>
  
  <p>The situation is I had a complex form that worked fine statically but I 'made it better' by making it submit using an AJAX request.</p>
  
  <p>Now the url of the page doesn't change to have the parameters in it like before but I can see the fully qualified url using firebug.</p>
  
  <p>What I am aiming to do is get this url and make a button to link to it so that the user can bookmark it because at the moment search results cannot be bookmarked.</p>
  
  <p>Sorry if this is in anyway an exact duplicate but any help and advice is greatly appreciated.</p>
  
  <p>This is my AJAX request(s) (they are basically the same but I have two forms presented as one form to the user, a simple search and a toggled advanced search) :</p>
  
  <pre><code>// setup AJAX request for simple search
  $simpleform = $('#search');
  $simpleform.submit(function() {
      $.ajax($simpleform.attr('action'), {
          data: $simpleform.serialize(),
          dataType: 'html',
          url: 'docsearch.php',
          type: 'GET', 
  
          beforeSend: function() {
              var $load = $('#loadingmessage');
              $('#search_results').fadeOut(1000);
              $load.hide().fadeIn(1000);
  
              if (!$load.length)
              {
                  $load = $('&lt;div id="loadingmessage"&gt;').appendTo($('#placeholder'));
              }
  
              $load.html('Searching... Please wait...');
  
              // disable both search buttons
              $('.submit').attr('disabled', 'disabled');
              $('.submit').addClass("disabled");
  
              $('#advancedsearchbutton').attr('disabled', 'disabled');
              $('#advancedsearchbutton').addClass("disabled");
          },
  
      success: function(response) {
          // response is the text sent back by server
  
          // find the search_results div in the response and insert it after the placeholder div
          $(response).find('#search_results').insertAfter($('#placeholder')).fadeIn(1000); 
          // re-initialise lightbox and dataTable plugins
          $('a.lightbox').lightBox();
          $('#test-docs-table').dataTable( {
                  "sPaginationType": "full_numbers",
                  "sDom": 'Rlfrtip',
                  "aoColumns": [
                      null,
                      null,
                      { "sType": "title-numeric" },
                      null
                  ]
          });
      },
  
      complete: function() {
          // hide loading message:
          $('#loadingmessage').fadeOut('slow');
  
          // enable both search buttons
          $('.submit').removeAttr("disabled");
          $('.submit').removeClass("disabled");
  
          checkDropdowns();
      }
  });
  
  return false; // Cancel default event
  });
  // end AJAX request
  
  // setup AJAX request for advanced search
  $form = $('#advancedsearchform');
  $form.submit(function() {
      $.ajax($form.attr('action'), {
          data: $form.serialize(),
          dataType: 'html',
          url: 'docsearch.php',
          type: 'GET', 
  
          beforeSend: function() {
              var $load = $('#loadingmessage');
              $('#search_results').fadeOut(1000);
              $load.hide().fadeIn(1000);
  
              if (!$load.length)
              {
                  $load = $('&lt;div id="loadingmessage"&gt;').appendTo($('#placeholder'));
              }
                $load.html('Searching... Please wait...');
  
              // disable both search buttons
              $('.submit').attr('disabled', 'disabled');
              $('.submit').addClass("disabled");
  
              $('#advancedsearchbutton').attr('disabled', 'disabled');
              $('#advancedsearchbutton').addClass("disabled");
          },
  
      success: function(response) {
          // response is the text sent back by server
  
          // find the search_results div in the response and insert it after the placeholder div
          $(response).find('#search_results').insertAfter($('#placeholder')).fadeIn(1000); 
          // re-initialise lightbox and dataTable plugins
          $('a.lightbox').lightBox();
          $('#test-docs-table').dataTable( {
                  "sPaginationType": "full_numbers",
                  "sDom": 'Rlfrtip',
                  "aoColumns": [
                      null,
                      null,
                      { "sType": "title-numeric" },
                      null
                  ]
          });
      },
  
      complete: function() {
          // hide loading message:
          $('#loadingmessage').fadeOut('slow');
  
          // enable both search buttons
          $('.submit').removeAttr("disabled");
          $('.submit').removeClass("disabled");
  
          $('#advancedsearchbutton').removeAttr("disabled");
          $('#advancedsearchbutton').removeClass("disabled");
      }
  });
  
  return false; // Cancel default event
  });
  // end AJAX request
  </code></pre>