jquery ajax call works local but not in cloud preview: No Transport
Hello developer,
I try to build a webapp that takes of a webpage, extracts (scrapes) a part of it and then displays it the part inside an own UI.
Getting the external webpage is done with jquery-ajax. I currently use 1.8.3 ( I have used the 1.7, but is was also not successful)
In cloud-preview, I get an ajax exception: "No Transport"
My ajax call looks like this:
[CODE]
$.ajax({
url: Scraper.articleURL,
type: 'GET',
dataType: 'html',
success: Scraper.gotArticle,
error: Scraper.notGotArticle
});
[/CODE]
Before I tried the direct load-method from jquery, but this has also not worked.
Does anybody has an idea what the problem is?
Regards
Karsten Meier
Re: jquery ajax call works local but not in cloud preview: No Transport
jQuery is not fully supported by the S40 Web App platform - so this is expected.
The normal ajax works fine,
[CODE]
var ajaxRequest = {
URL: "http://www....",
init: function(){
//URL, success callback, failure callback
this.connect(this.URL, this.responseHandler, this.failureHandler);
},
responseHandler: function(data) {
// Process data
},
failureHandler: function(reason){
// Handle failure
},
connect: function(url, successCb, failCb) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader("Accept","application/json");
xmlhttp.setRequestHeader("Cache-Control", "no-cache");
xmlhttp.setRequestHeader("Pragma", "no-cache");
var that = this;
xmlhttp.onreadystatechange= function() {
if (xmlhttp.readyState == 4 ){
if(xmlhttp.status == 200){
if (xmlhttp.responseText != null) {
successCb.call(that, xmlhttp.responseText);
}else{
failCb.call(that, "Empty response.");
}
}else{
failCb.call(that, "Connection failed: Status "+xmlhttp.status);
}
}
};
xmlhttp.send();
}
};
ajaxRequest.init();
[/CODE]
Re: jquery ajax call works local but not in cloud preview: No Transport
Thank you croozeus,
it now works in cloud preview, and more important, also on the device.
Of course all the jquery animations do not work on the proxy browser. But selecting and DOM-manipulation works quite good so far, and jquery it is used in several example projects.
So I hoped the jquery-ajax does also work.
Regards
Karsten Meier
Re: jquery ajax call works local but not in cloud preview: No Transport
Glad it works! Happy to help :)
Re: jquery ajax call works local but not in cloud preview: No Transport
A follow-up: In the Location-webinar, they succesfully used jquery with ajax. The said we need to set
"crossDomain: false," when we use a success- or failure-handler.