where can I display the error back from server Ajax REST requests ?
where can I display the error back from server Ajax REST requests ?
I edited this question to focus on a specific business case :
I am sending and processing correctly the client/server Ajax REST requests, but upon error ( generic) when sending back correctJSON response , nothing is displayed in the Editor form ...
@data = {error: "a notification"}
render json: @data.to_json , status: 403 #Forbidden Attributes
the ajax response is , detected correctly in my editor
but where and how can I display this error ? ( in the form ?)
and can I close the form programmatically ?
EDIT error!
returned: {
"readyState": 4,
"responseText": "{\"error\":\"Sorry forbidden attributes. Please contact your system admin.\"}",
"responseJSON": {
"error": "Sorry forbidden attributes. Please contact your system admin"
},
"status": 403,
"statusText": "Forbidden"
}
Here is my editor setup
editor = new $.fn.dataTable.Editor( {
ajax:{
...
edit: {
type: 'PUT',
dataType : "json",
success: function (json) {
console.log("EDIT success!");
console.log("returned json: "+JSON.stringify(json, null, 2));
//success( json );
},
error: function (xhr, error, thrown) {
console.log("EDIT error!");
console.log("returned: "+JSON.stringify(xhr, null, 2));
//error( xhr, error, thrown );
}
},
...
This discussion has been closed.