My function is supposed to display the response text that comes back from ex.responseText. However, every time I attempt it, it returns as "undefined" even though the text is there.
onError: function (ex) {
$('<div>' + ex._message + '</div>').dialog({
modal: true,
resizable: false,
title: "Items",
buttons: { "Okay": function () { $(this).dialog("close"); } }
});
}
I then tried the following:
$('<div>' + ex.responseText + '</div>').dialog({
modal: true,
resizable: false,
title: "Items",
buttons: { "Okay": function () { $(this).dialog("close"); } }
});
However, this shows me the error in the format:
{"message":"You have entered duplicate items. Please remove."}
I simply want it to display the actual message:
You have entered duplicate items. Please remove.
without the curly brackets and "message" text.
I also attempted:
var message = JSON.parse(ex.responseText)._message;
$('<div>' + message + '</div>').dialog({
modal: true,
resizable: false,
title: "Items",
buttons: { "Okay": function () { $(this).dialog("close"); } }
});
But it continues to return as undefined. What am I doing incorrectly?