Page 2 of 2

audio stopped when invoke RESTservice

Posted: Mon Jul 07, 2014 7:07 am
by Kateryna Grynko

Hi Danny,

Click 'Create new', select 'Generic (custom JavaScript implementation)', open "JavaScript Implementation" and here replace function codeprocess/code with the above.


audio stopped when invoke RESTservice

Posted: Mon Jul 07, 2014 1:53 pm
by Danny Nguyen

Hi Katya,

I added the following codes in JavaScript implementation. I also used "Automatically Create from Sample Response" for artist, title, album_art... etc. I've mapped the response. I invoked the service on the page load. However, it did not show the content on the startpage. I have exported and tested on my android phone. Can you please help?

Thanks,

Appery.get_music_data = Appery.createClass(null, {

Code: Select all

 init: function(requestOptions) { 
     this.__requestOptions = $.extend({}, requestOptions); 
 }, 

 process: function(settings) { 
     settings.beforeSend(settings); 
     if (this.requestOptions.echo) { 
         settings.success(this.requestOptions.echo); 
     } else { 
         var response = $.ajax({ 
             url: "[url=http://www.hosannacc.org/hyvongradio/radio_rest.php]http://www.hosannacc.org/hyvongradio/...[/url]", 
             async: true 
         }); 
         settings.success(JSON.parse(response.responseText)); 
     } 
     settings.complete('success'); 
 }  

});


audio stopped when invoke RESTservice

Posted: Tue Jul 08, 2014 10:10 am
by Kateryna Grynko

Hi Danny,

If it is your PHP server, allow any domain to access it: http://stackoverflow.com/questions/68...


audio stopped when invoke RESTservice

Posted: Tue Jul 08, 2014 6:17 pm
by Danny Nguyen

Hi Katya,

I added the following code in my php (http://www.hosannacc.org/hyvongradio/...) on the server.

header("Access-Control-Allow-Origin: * ");

It does not work.


audio stopped when invoke RESTservice

Posted: Wed Jul 09, 2014 9:21 am
by Kateryna Grynko

Hi Danny,

Let's try the following solution. Use server code: http://devcenter.appery.io/documentat...

1) Add this JS to server code: prevar XHRResponse = XHR.send("GET", "http://www.hosannacc.org/hyvongradio/radio_rest.php", {});
response.success(XHRResponse.body, "text/json");/pre2) Create Generic service with the following realization:preAppery.myjs = Appery.createClass(null, {
init: function(requestOptions) {
this.__requestOptions = $.extend({}, requestOptions);
},

process: function(settings) {
settings.beforeSend(settings);
var response = $.ajax({
url: "https://api.appery.io/rest/1/code/bb147988-eeb3-4aee-9bdc-3bb6438a6e6e/exec",
async: true,
success: function(data) {
Apperyio("labelName").text(data[0].artist);
}
});
}
});/preWhere myjs is name of JS file with service realization,
labelName is a name of a label where you display an executor name,
and so on for other parameters...


audio stopped when invoke RESTservice

Posted: Thu Jul 10, 2014 3:55 pm
by Danny Nguyen

Katya,

I solved my problem using cross domain server code and added HTML box on apperry to call javascript.

Thanks.

Now. I have another problem which I will create a new topic. The swipe is delayed on my phone.