2

Hi i am executing an ajax call from javascript in BB10 cascades using webview as below

$.ajax({
    url: internalserverip,
    type: "POST",
    cache: false,
    data: pjsonstring,
    dataType: 'json',
    success: function(json) {
    },
    error: function (xhr, statusText, throwError) {
        alert(JSON.stringify(xhr)); 
            // alerts {"readyState":4,"status":404,"statusText":"error"}
        alert(statusText); // alerts error
        alert(throwError); // alerts null
    },
    async: false
});

It always goes to error function, and alerts the same.

sanj15041
  • 21
  • 3
  • 1
    Does the request reach the server? What do the server logs say? – RoToRa Oct 28 '13 at 11:04
  • Request has reached server and processed accordingly. But ajax call is unable to get the response sent by server and goes in error block. – sanj15041 Oct 29 '13 at 05:23

1 Answers1

0

@Sanj15041: We know that 404 http code means the content are not found!

You are getting this error maybe because your internalserverip url is not addressing to a valid content on your server Or the server returns 404 error according to the data you are sending as parameters

What to do?

Well:

  • Please verify if your internalserverip url is being spelled correctly by alerting it(look code bellow)
  • Check if your server is configured to receive/process POST requests on that url

  • Navigate to your internalserverip url with the same data (pjsonstring) within the same directory, and check if the result! Maybe it returns 404 too!

  • be sure your url (internalserverip) returns jsonEncoded data

  • Paste Your Server Side Code here : So, We'd be able to understand what is not working

Alert your error in case of error to check if it is what you wish

 $.ajax({
    url: internalserverip,
    type: "POST",
    cache: false,
    data: pjsonstring,
    dataType: 'json',
    success: function(json) {
},
error: function (xhr, statusText, throwError) {
    alert("url: "+internalserverip+"\n Parameters: "+pjsonstring+"\n returns : "+JSON.stringify(xhr)); 
    alert(statusText); // alerts error
    alert(throwError); // alerts null
},
async: false
});

In fine: This is not the cause but you don't need to say {cache:false}, because post requests data are never cached!

Good luck

Bellash
  • 7,560
  • 6
  • 53
  • 86