Showing posts with label Jquery. Show all posts
Showing posts with label Jquery. Show all posts

Wednesday, January 25, 2012

IE Caches Jquery Ajax Request

Do you know what's the time now, while I write this post? It's 2:00 am in the morning. I was asked to fix a Jquery issue happening only in Internet explorer.

There was a piece of code which makes an ajax request to the server periodically. But this code only works  once.  This problem is seen only in Internet explorer. After scratching my head for a while I finally realized that IE caches ajax requests.

The solution is to use the following code:


$.ajaxSetup ({
   cache: false
});

Setting cache to false also appends a query string parameter, "_=[TIMESTAMP]", to the URL. So if you have  long query string as the ajax request this might be a problem. I am  not sure, I but I guess so.

Happy Hacking!


Tuesday, January 05, 2010

JSON - Jquery

JSON & Jquery might have stormed well in the AJAX/WS world. But the right documents are missing. I was banging myu head for a few hours, on how to get a json object from a codebehind:

I was building a JSON object:{name:myvalue}

Tried all ways and it never workd in the Ajax method:

$.post("test.aspx?tbg=yu", $("#form1").serialize(),
function(data) {
alert(data.name); ---->Always returned undefined. In firebug it was not showing at all.


The Right solution is {name:'myvalue'}. This ******ing >>>>'<<<<< style="font-style: italic;">-Happy Hacking