Ben Ziegler
Ben Ziegler

Reputation: 973

extra querystring data on jQuery.ajax()

For all intense purposes what I have is working, however, I wanted to know what this extra querystring data is and where it's coming from.

jQuery.ajax({
        url: 'MyFile.aspx/ProcessRequest',
        data: JSON.stringify({status: status }),
        async: false,
        dataType: 'application/json',
        cache: false,
        success: function (data) {
  // ... do stuff with data...
  });

Using tamperdata and also viewing the Request.QueryString in the debugger the resulting url is:

http://localhost/Folder/MyFile.aspx/ProcessRequest?_=1298057136790&{%22status%22:%22pqs%22}

So where does this _1298057135790 come from and why is it there?

Upvotes: 1

Views: 562

Answers (2)

Adeel
Adeel

Reputation: 19238

Browser and proxy server often cache the requests. By appending this, you will get fresh data. you have used the following in code.

cache:false

Changing this will remove it but it is a great chance that you may get old data, even if browser cache is disabled.

Upvotes: 2

Mike Marshall
Mike Marshall

Reputation: 7850

I believe that is an attempt by stringify() or ajax() to randomize a portion of the URL so that you don't get cached data from the browser back, but get real live data from the server instead. Many browsers and web servers will cache based on the uniqueness of the URL

Upvotes: 0

Related Questions