Ajax method not calling server side Controller method






2.50/5 (3 votes)
Solution if Ajax method not calling Controller method every time its invoked
Introduction
This might help in firing the Controller method, everytime its invoked via an Ajax call.
Background
My ajax call was not calling the Controller method on the server side, even though it was invoked everytime.
Using the code
With cache:false, i was able to have the Server side controller method fired everytime, the function was invoked from the page.
var selectedGuid;
can_Edit_Submit_Approve_Order(selectedGuid) //function call in my page
function can_Edit_Submit_Approve_Order(opportunityId)
{
$.ajax({
url: "/Order/Can_Edit_Submit_Approve_Order/?opportunityId=" + opportunityId,
type: "GET",
cache: false,
success: function (result) {
if (result.length > 0)
{
//custom logic to enable / disable releavant buttons here
}
else
{
//code for default button disable
}
}
});
}
Points of Interest
Without cache:false, i did verify that the controller call was being by-passed/ missed due to some reason (not for the first time though but consistently thereafter).