Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$.Ajax without "_" querystring parameter

I'm using the $.ajax method to dynamically include plugin script files, unfortunately since this entire project is hosted in Dynamics CRM 2011, no querystring parameters can be passed to this request without rubbing CRM up the wrong way.

So executing the following:

$.ajax({
    url: includeUrl, // == "Templates.js"
    dataType: "script",
    success: function (includedFile) {
        window.Includes.push(includedFile);
    }
});

will return 500 - Internal Server Error looking at the firebug console I have requested the following URL:

http://server:5555/Organisation/WebResources/grid_/Templates.js?_=1366828753001

which has got this _=1366828753001 parameter appended by the $.Ajax method.. CRM doesn't like this very much.. I ask this knowing I'm probably between a rock and a hard place but is there any way to call $.ajax forcing it not to append this ID into the querystring?

Full error from CRM:

<description>CRM Parameter Filter - Invalid parameter '_=1366828753001' in Request.QueryString on page /Organisation/Handlers/WebResource.ashx
The raw request was 'GET /Organisation/WebResources/grid_/Templates.js?_=1366828753001' called from http://server:5555/Organisation/WebResources/grid_/EditableGrid.htm.</description>
like image 677
Dead.Rabit Avatar asked Apr 24 '13 19:04

Dead.Rabit


1 Answers

Set cache: true as a parameter of your $.ajax() call

That query string appended by jQuery to prevent caching of the resource being requested.

like image 133
Barry Chapman Avatar answered Oct 26 '22 04:10

Barry Chapman