1

As in title, i have an asp.net 4.0 web forms project working fine. As i try to move jquery from 1.7.2 to 1.9.0 i get

HTTP 405.0 - Method Not Allowed

As i try to load htm files through ajax. Sample code causing error

$("#samplediv").load("/htmlParts/ComunicazioniAlerts.htm?p=" + now(), function () {
    alert('loaded');
}); 

Code that works perfectly with older jquery version.

I'm putting the upgrade to stand-by, seems a method/verb problem but shows only when updgrading jquery, as if they changed the way they require pages.

Faber75
  • 106
  • 8
  • 1
    Similar to http://stackoverflow.com/questions/14400626/script-does-not-work-with-jquery-1-9/14400792#14400792 and my answer to that question applies here too. – Spudley Jan 18 '13 at 15:42
  • Wrong, i checked the upgrade list before posting and it has nothing about my problem. I have no scripts in my html. I just found the problem, detailed below. I still have not found a nice answer, if you want to help – Faber75 Jan 18 '13 at 15:57
  • of course, the easiest answer is simply not to upgrade jQuery at all. 1.7 still works, so there's nothing to stop you carrying on using it unless you have a specific need to use the new stuff in 1.9. (or a half-way house option would be to upgrade to 1.8) – Spudley Jan 18 '13 at 16:04

1 Answers1

1

Found. I use many ajax calls in my app and to avoid repeating i put on top of my app this

$.ajaxSetup({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    data: "{}",
    dataType: "json"
});

In 1.7.2 this wasn't applying to $.load() that kept using GET method.
Now in 1.9.0 also $.load considers the $.ajaxsetup, sends requests with POST method for htm files and IIS refuses the request.

Possible workaround:
- on IIS enable POST verb on static elements (i don't know how to do and it's a trick to put up on all the iis i might use. awful)
- remove POST from $.ajaxsetup, adding again to all the $.ajax requests (boring and lengthy)
- replace all $.load with $.get, having to write code to add the resulting html to desired div (again, boring and lengthy).

Any workaround is appreciated.

Faber75
  • 106
  • 8