blackberry webworks app getting timed out - ajax

$.ajax({
type: 'POST',
url: "http://myurl:port/projectpath.action",
data: formInput,
dataType: "TEXT",
timeout:600000,
async: true,
success:function(jqXHR, textStatus, errorThrown){
alert("error :" + textStatus);
alert("incoming Text :" + jqXHR.responseText);
alert("What ErrorThrown :" + errorThrown);
$('#loader').hide();
window.location.replace("paymentResult.html");
},
error:function(jqXHR, textStatus, errorThrown){
alert("error " + textStatus);
alert("incoming Text " + jqXHR.responseText);
alert("What ErrorThrown" +errorThrown);
$('#loader').hide();
//alert(xhr.status+" Server Unavailable! Please try again later");
}
});
return false;
});
I'm getting timed out although I am setting the ajax time out..and in the config file I have also mentioned the timeout... still it is getting timed out...
alert("What ErrorThrown" +errorThrown);
The alert message above shows and in my config file, my parameters passed are:
"rim:connection timeout="600000""
"id"TCP_WIFI"/id"
"id"MDS"/id"
"id"BIS-B"/id"
"id"TCP_CELLULAR"/id"
"id"WAP2"/id"
"id"WAP"/id"
"/rim:connection"
Please help me.
Thanks in advance

In your config.xml you should also be setting up an access element.
<access uri="*" subdomains="true" />
Can you confirm if you're doing this already? If so, and it still gets no response, could you tell me what OS/device you're targeting? If it's running BlackBerry OS 7 or higher (or PlayBook/BB10) you can use Remote Web Inspector to watch real-time what's happening with your ajax request, and debug it that way.
More on Remote Web Inspector...

Are you seeing the same results when using WiFi only? Turn off the mobile network, connect to WiFi and see if you get the same result.

Related

Web Core API Post request get blocked, sometimes

I have this AJAX call to my Web Core API;
saveProperty = function (url, data, callback, errorCallback) {
$.ajax({
async: true,
type: "Post",
url: url,
data: data,
contentType: "application/json",
dataType: "text"
})
.done(callback)
//.fail(errorCallback);
.fail(function (jqXHR, textStatus, errorThrown) {
alert("Something went wrong: " + textStatus + " " + errorThrown);
errorCallback();
});
}
Sometimes it works, more often it does not.
When I use Fiddler and it works, I see
And when it doesn't I see;
EDIT - I can be more helpful now in describing this problem.
if I have Fiddler up and running before I lanch the aplication in development, I do not get this bug.
Otherwise I do get this bug.
Why is that? I would love to know.
The error is HTTP Error 401.2 - Unauthorized
Why would this happen with the same code?

jquery ajax calls gives 404 for Windows phone

I build my software with Jquery mobile. In my code I use Ajax JSONP calls to retrieve information from a server. This gives no problem when testing in my browser. With phonegap / cordova I have generated an Android APK and a Windows XAP file. The Android build gives also a success, but when running on a Windows phone I get a 404 error.
Does anybody have a clue what could be the reason for this 404 error; could it have to do with permissions?
Many thanks in advance.
In the config.xml I have added: access origin="*"
The Ajax call looks like:
function retrieveProvincies()
{
$.ajax({url: 'http://www.itclubsupport.nl/test/AppPHPtest/AppIngang.php',
method: 'POST',
data: {
indicatieTestenApp: 'yes',
soortRequest: 'retrieveProvincies',
klantnaam: 'klantITclubsupport'
},
dataType: "jsonp",
success: function (response) {
alert('works!');
},
error: function(jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
alert('Status ' + jqXHR.status + ' received when retrieving provincies. Error: '
+ textStatus + '; ' + errorThrown);
}
})
}

ajax always going to success

I'm having troubles with ajax. my code runs well, but then, it always goes to success.
dataLogin = 'mail=' + $('#login_mail').val() + '&pass=' + $('#login_password').val() + '&on=' + manter_ligado;
$.ajax({ url: 'modules/login.php?' + dataLogin,
type: 'POST',
//data: dataLogin,
data : {
mail : $('#login_mail').val(),
pass : $('#login_password').val(),
on : manter_ligado
},
success: function(data) {
alert(data);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
can anyone help me with this?
Also, I'm using sublime to code, and it gives me some errors on the ajax, but I can't seem to correct them, it might help knowing this
Also, I know that the php works, because I can make the login on the website, but the problem I have is when the user/pass is incorrect
Make sure the server is returning an error code of 500.
In the php.ini file, make sure displayErrors is set to Off
To get the ajax to hit the failure function, you may need to throw an error when one occurs in your PHP

jQuery Ajax Call, give offline/ "not able to connect" message

Yes, i have a normal ajax call that calls imback.php, that checks for new stuff if you have been blur for 50 sec.
Now if you disconnects from the internet, and when you get on focus, it will not be able to get imback.php.(i think its 404 error) So i would like to make a offline msg/timeout thing, so it alerts "You have no internet connection or something else went wrong".
How can i do that?
$.ajax({
url: 'imback.php',
success:function(msg) {
$('.NewStuffSinceActive').prepend(msg);
}
})
You can use the error callback for this:
$.ajax({
url: 'imback.php',
success: function(msg) {
$('.NewStuffSinceActive').prepend(msg);
},
error: function(xhr, status, error) {
alert("An error occured: " + error);
}
})

MVC2 One Async Call, Multiple Async Updates

I have an operation on my Page that then requires 3 long (few seconds each) operations to be performed in series. After each operation is performed though, I would like the controller to return a partial view and have the page update with a status (keeps the user informed, I find that if people know that stuff is happening they worry less). Is there a MVC 'way' of doing this, or should I just use jQuery to do it?
Thanks.
You will want to use jQuery to issue three separate calls to three separate control methods and update the three areas of the page upon return separately.
The only way to "bunch" up calls would be to combine it all into one, but you can't get return values fired back to the client upon return of more than one call (almost like streaming, there's nothing listening on the client end after you return your first result set, that connection is closed).
So I have created a slight hack, that seems to work:
On the client side I have:
function onClickHandler() {
updateUI("Beginning Batch...");
setTimeout(klugeyClick, 0);
}
function klugeyClick() {
$.ajax({ type: "GET", dataType: "json", url: "/ControllerName/Action1", success: function(msg) { updateUI(msg) }, async: false, error: function(XMLHttpRequest, textStatus, errorThrown) { updateUI("Action1 Error: " + XMLHttpRequest + " -- " + textStatus + " ---- " + errorThrown); } });
setTimeout(klugeyClick2, 0);
}
function klugeyClick2() {
$.ajax({ type: "GET", dataType: "json", url: "/ControllerName/Action2", success: function(msg) { updateUI(msg) }, async: false, error: function(XMLHttpRequest, textStatus, errorThrown) { updateUI("Action2 Error: " + XMLHttpRequest + " -- " + textStatus + " ---- " + errorThrown); } });
setTimeout(klugeyClick3, 0);
}
function klugeyClick3() {
$.ajax({ type: "GET", dataType: "json", url: "/ControllerName/Action3", success: function(msg) { updateUI(msg) }, async: false, error: function(XMLHttpRequest, textStatus, errorThrown) { updateUI("Action3 Error: " + XMLHttpRequest + " -- " + textStatus + " ---- " + errorThrown); } });
}
function updateUI(result) {
$("#UIelement").text(result);
}
On the server side I have:
Function Action1() As JsonResult
System.Threading.Thread.Sleep(3000)
Return Json("Operation One Complete...")
End Function
Function Action2() As JsonResult
System.Threading.Thread.Sleep(3000)
Return Json("Operation Two Complete...")
End Function
Function Action3() As JsonResult
System.Threading.Thread.Sleep(3000)
Return Json("Operation Three Complete...")
End Function
Now I have two problems. First, I would like to have a follow up message that displays "Batch Complete" but following the same pattern and just adding another 'klugeyClick' with a call to UpdateUI (with or without a seTimeout) causes the last operation message not to be displayed. I think the callback within the jQuery.ajax method makes this kluge work somehow but without an ajax call, I can't put any follow-up messages.
The next problem is that although all my calls are getting to my webservice and are returning json results just fine, I always get an error coming back from the jQuery callback. Any ideas why this might be?
Thanks.
So as far as I can tell, the only way to get a Follow up message to appear the way I want it do (i.e. a few seconds after my last operation) is to have a dummy webservice method that I call that returns the last message after a delay... crumby.
Now my last problem is that all of my calls to my jsonResult actions come back with a textStatus of 'error' to the client. Now according to the docs this means an http error, but how could there be an http error if the method was called on the server side correctly and a Json result was produced (verified by setting a breakpoint on the server)?
For our site we have a big action that requires some time. That action is composed by subactions, we aggregate the results and we build a nice view.
One year ago:
We were doing that in a sequence: action1, then action2, etc.
We had that typical page of: please wait.
Tricks that can help you:
We do parallel requests on the server side.
We wait for results in a results page. The javascript there needs some time to load, so while the server searches, we load the page.
We ask the server every second: have you finished? And we get partial results as the different actions complete.
I don't know if you can apply all of these things to your problem but some of then can be really nice.
We don't use MVC, we use some asmx services with jQuery and ajax.
The reason your "kludgy" solution works is because the setTimeout() method creates an event. Thus your logic is:
Update UI
Setup event for step 1:
Start "ajax" call
Wait for "ajax" to finish
Setup event for step 2
Start "ajax" call
Wait for "ajax" to finish
Setup event for step 3
Start "ajax" call
This is precisely what the callback feature of ajax() is for.
function Step1() {
$.ajax({
type: "GET",
dataType: "json",
url: "/ControllerName/Action1",
success: function(msg) {
updateUI(msg);
Step2(); // call step 2 here!
},
async: true, // don't block the UI
error: function(XMLHttpRequest, textStatus, errorThrown) {
updateUI("Action1 Error: " + XMLHttpRequest + " -- " + textStatus + " ---- " + errorThrown);
}
});
}
function Step2() {
// similar to step one
}

Resources