The jQuery.load () function removes my <HttpPost ()> action instead of my <HttpGet ()>
I have an overloaded action in my method, one of which is declared along with the other.
I use the Post method to handle my form submit button, which works great.
I wanted the HttpGet method to handle the jQuery.load () action, but instead it was also caught by my Post method.
Any idea what I am missing? Do I have to explicitly reference .get () or .ajax () in order to perform the correct action?
Thanks!
-Ben
The .load method can send an AJAX HTTP POST request, as indicated in the documentation:
The POST method is used if data is provided as an object; otherwise, it is assumed that GET.
for instance
$('#result').load("/foo", { id: 123 }, function(result) { }); will send a POST request.
If you really want to use $.get or $.ajax with type: 'GET' . Also, remember that if you use a GET request for AJAX, some browsers may cache the results and you get into trouble or at least some weird behavior, so if you want fresh content from your server to use $.ajax with the cache: false parameter cache: false .