I have an overloaded action in my method, one declared with and the other with .
I use the Post metod to handle my form's submit button, which works fine.
I wanted the HttpGet method to handle a jQuery .load() action but that is instead also being caught by my Post method.
Any idea what I'm missing? Do I have to explicitl call a .get() or .ajax() to hit the right action?
Thanks!
-Ben
jQuery load() Method The load() method loads data from a server and puts the returned data into the selected element. Syntax: $(selector). load(URL,data,callback);
You can use jQuery to support both synchronous and asynchronous code, with the `$.
Method 1: Using HTML: One can use the anchor tag to redirect to a particular section on the same page. You need to add ” id attribute” to the section you want to show and use the same id in href attribute with “#” in the anchor tag.
The browser performs a JavaScript call to the Ajax engine. In other words, create an XMLHttpRequest object. In the background, an HTTP request is made to the server and the appropriate data is retrieved. HTML, XML, or JavaScript data is returned to the Ajax engine which then delivers the requested data to the browser.
The .load
method could send an HTTP POST AJAX request as stated in the documentation:
The POST method is used if data is provided as an object; otherwise, GET is assumed.
For example
$('#result').load("/foo", { id: 123 }, function(result) {
});
will send a POST request.
If you want to be sure use $.get
, or $.ajax
with type: 'GET'
. Also don't forget that if you use GET request for AJAX some browsers might cache the results and get you into trouble or at least some weird behavior, so if you want fresh contents from your server use $.ajax
with cache: false
parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With