Is Safari on iOS 6 caching $.ajax results?

After a bit of investigation, turns out that Safari on iOS6 will cache POSTs that have either no Cache-Control headers or even “Cache-Control: max-age=0”. The only way I’ve found of preventing this caching from happening at a global level rather than having to hack random querystrings onto the end of service calls is to set … Read more

Serializing to JSON in jQuery [duplicate]

JSON-js – JSON in JavaScript. To convert an object to a string, use JSON.stringify: var json_text = JSON.stringify(your_object, null, 2); To convert a JSON string to object, use JSON.parse: var your_object = JSON.parse(json_text); It was recently recommended by John Resig: …PLEASE start migrating your JSON-using applications over to Crockford’s json2.js. It is fully compatible with … Read more

How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

From the jQuery documentation: you specify the asynchronous option to be false to get a synchronous Ajax request. Then your callback can set some data before your mother function proceeds. Here”s what your code would look like if changed as suggested: beforecreate: function (node, targetNode, type, to) { jQuery.ajax({ url: ‘http://example.com/catalog/create/’ + targetNode.id + ‘?name=” … Read more

Abort Ajax requests using jQuery

Most of the jQuery Ajax methods return an XMLHttpRequest (or the equivalent) object, so you can just use abort(). See the documentation: abort Method (MSDN). Cancels the current HTTP request. abort() (MDN). If the request has been sent already, this method will abort the request. var xhr = $.ajax({ type: “POST”, url: “some.php”, data: “name=John&location=Boston”, … Read more

Disable same origin policy in Chrome

Close chrome (or chromium) and restart with the –disable-web-security argument. I just tested this and verified that I can access the contents of an iframe with src=”http://google.com” embedded in a page served from “localhost” (tested under chromium 5 / ubuntu). For me the exact command was: Note : Kill all chrome instances before running command … Read more

How do I format a Microsoft JSON date?

eval() is not necessary. This will work fine: var date = new Date(parseInt(jsonDate.substr(6))); The substr() function takes out the /Date( part, and the parseInt() function gets the integer and ignores the )/ at the end. The resulting number is passed into the Date constructor. I have intentionally left out the radix (the 2nd argument to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)