I have an ajax call to JsonAction
$.ajax({
url: "/Cancel/",
context: document.body,
success: function (result) {
if (result.indexOf("Authorize") != -1) //indexOf not supported?
window.location.replace("/Account/LogOn");
//...
};
Why is that happening?
Also i was trying to go like that:
var responce = result;
if (responce.indexOf("Authorize") != -1)
and
var responce = $(result);
if (responce.text().indexOf("Authorize") != -1)
But all the same. Ned help how to make .indexOf working.
The server response is likely being interpreted as JSON, and being converted into a data object automatically by jQuery. In that case it likely won’t have an
indexOfmember, and it certainly won’t be a function.Try forcing jQuery to leave the response as text by setting the
dataTypeattribute of your settings object to “text”: