Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Display service response error message on application as an alert.

Update I got it to post an error now using this code, and I had to create a local resource notFound and map the two together.

var errorText = localStorage.getItem('notFound') ;
if(errorText != ""){
localStorage.removeItem('notFound');
alert(errorText);
}

But I have the issue of the error it displays saying null, how do i change the error text?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Display service response error message on application as an alert.

I think "not found" is the error message. Based on the screen shot you posted, you are getting 404 error (not found). You need to make sure you are invoking the service correctly.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Display service response error message on application as an alert.

I'm not sure why it's happening just by looking at the code. You need to add debug statements after each line and see what's happening. It looks you are getting a 404 from the service -- that means you are not invoking the service correctly.

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Display service response error message on application as an alert.

Update I got it to post an error now using this code, and I had to create a local resource notFound and map the two together.

var errorText = localStorage.getItem('notFound') ;
if(errorText != ""){
localStorage.removeItem('notFound');
alert(errorText);
}

But I have the issue of the error it displays saying null, how do i change the error text?

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Display service response error message on application as an alert.

Im confused.... If I invoke the service properly I get the data I want. This notFound error is the error I want to invoke in this case, but I want to display this error to the user. But I have been able to display an error box now but the error box is either blank or displays null.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Display service response error message on application as an alert.

If that's the error that you need, print the textStatus argument: http://docs.appery.io/documentation/r...

You can also print the jqXHR object and you will see the error inside the object.

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Display service response error message on application as an alert.

I dont think im writing the code properly, would i leave this code and add it to the end? Because no matter how I write the jqXHR the page never loads with it in the java.

var errorText = localStorage.getItem('notFound') ;
if(errorText != ""){
localStorage.removeItem('notFound');
alert(errorText);
} function(jqXHR, textStatus, errorThrown) {}

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Display service response error message on application as an alert.

Hello! If you get "404 page not found" then mapping doesn't work and service Success event is not invoked. But Complete event is invoked no matter if service call was successful or not. It this event jqXHR object is passed. On service Complete event add the following code preconsole.log(jqXHR)/pre and check developers console. You can use jqXHR data to output error message.

Robert Larsen
Posts: 0
Joined: Fri Aug 02, 2013 6:56 am

Display service response error message on application as an alert.

I kinda see what you are saying could you provide me with a little bit more detailed steps. I understand what you are saying about the mapping and service success. I added the code you provided to complete event. Here is what I get in console, when I invoke the error with the provided code. I apologize I know little to nothing about coding, learning as I go. Image

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Display service response error message on application as an alert.

You should be getting the jqXHR object properties.. I'm not sure why you are simply getting [object Object]. Can you give it a try in Chrome and check with Chrome Dev. Tools.

Return to “Issues”