The ajax function below is encountering an error message with little information, simply stating "error":
var form = formInfo;
var url = $(formInfo).attr("action");
var data = $(formInfo).serialize();
$.ajax({
type: "post",
url: url,
data: data,
dataType: "text",
**cache: false,**
success: function (r) {
//do stuff here
}, error: function (r) {
//do some logging stuff here
}
});
I'm puzzled by the fact that when I manually run the same ajax call in the console, it works without any issues. Additionally, if I debug through the backend code using a breakpoint, the post goes through successfully. Do you have any insights into what might be causing this unexpected error?
EDIT: After further investigation, it appears that the problem stemmed from caching, and setting cache: false resolved the issue. EDIT 2: Another factor contributing to the problem was that window.location was being triggered before the ajax call finished executing, so we moved it to a function called within the success callback.