hb condo
Posts: 0
Joined: Mon Jul 14, 2014 7:38 am

Got 'undefined' parse error for service

I'm trying to setup / consume a Yahoo! RESTful service that has a callback and I am running into some issues:

  • Per the attached screenshot, the service test screen returns a response but is showing an error when attempting to automatically create a service response.

    Image

    To get around this, I manually created the Response.

    Image

  • When invoking the service, the Success event is not triggered but the Complete event is.

    How can I setup and consume this service? Any help is appreciated. Thanks.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Got 'undefined' parse error for service

Hello,

You get no JSON but JSONP in reply. You should remove request parameter callbackand and put in the configuration Data Type=JSONP Here you may find more info:
http://devcenter.appery.io/documentat...

hb condo
Posts: 0
Joined: Mon Jul 14, 2014 7:38 am

Got 'undefined' parse error for service

Hi, Evgene. Thank you for your reply. If I specify JSONP as the data type, then the callback parameter value is auto-generated which the RESTful service rejects. If I create a callback request parameter, then two callback values are passed. Is there a way to have a JSONP data type and a custom callback value? For this RESTful service, the callback must equal "YAHOO.Finance.SymbolSuggest.ssCallback".

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Got 'undefined' parse error for service

Hello,

Yes you can invoke "YAHOO.Finance.SymbolSuggest.ssCallback" in service "success" event.

So add JS event handler on success event for your service and populate it with following code:

pre

YAHOO.Finance.SymbolSuggest.ssCallback(data);

/pre

See details on scrren shot: http://prntscr.com/42s0in/direct

Regards.

hb condo
Posts: 0
Joined: Mon Jul 14, 2014 7:38 am

Got 'undefined' parse error for service

Thanks for the screenshot, Yurii. I added the code but I'm not sure how to implement the actual callback function. Can you advise on the next steps on how to work with the data parameter?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Got 'undefined' parse error for service

If you don't need invoke "YAHOO.Finance.SymbolSuggest.ssCallback" event handler you can work with returned data directly in the "success" event handler.

For example:

pre

//This line of code will print to the debug console. Please check it out to see what is in your "data" returned object.
condole.log(data);

alert(data);

alert(data.length);

/pre

Also if it will not help please specify what exactly you want to do.

Thanks & regards.

hb condo
Posts: 0
Joined: Mon Jul 14, 2014 7:38 am

Got 'undefined' parse error for service

Thank you for the quick reply. Below is how I call the service in jQuery, how can I incorporate this into Appery?
code
$.ajax({
type: "GET",
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "YAHOO.Finance.SymbolSuggest.ssCallback",
data: {
query: "msft"
},
url: "http://autoc.finance.yahoo.com/autoc"
});
/code
code
YAHOO.Finance.SymbolSuggest.ssCallback = function (data) {
alert(data.ResultSet.Result);
}
/code

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Got 'undefined' parse error for service

Hello,

You can add this code to custom realization of Generic service: http://devcenter.appery.io/documentat...

hb condo
Posts: 0
Joined: Mon Jul 14, 2014 7:38 am

Got 'undefined' parse error for service

We have tried the Generic service but we are having trouble getting it to work. Could you provide guidance based on the js provided above how we would setup a generic service?

Ideally, we would like to use a REST service configuration so could you be able to answer part of my question of Is there a way to have a JSONP data type and a custom callback value?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Got 'undefined' parse error for service

Hello,

Please follow the solution below:

1 Create generic service http://prntscr.com/434glf/direct.

2 Click "Add custom implementation"

3 Choose "new javascript" with name "genericService1JS". http://prntscr.com/434h6f/direct

4 Use following code in "JS" implementation:

pre

//Note replace "genericService1JS" with your value.
Appery.genericService1JS = Appery.createClass(null, {

Code: Select all

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

 process : function(settings) { 

     if(!self.YAHOO || !YAHOO.Finance || !YAHOO.Finance.SymbolSuggest) 
         self.YAHOO = {Finance: {SymbolSuggest: {} } }; 

     $.ajax({ 
         type: "GET", 
         dataType: "jsonp", 
         jsonp: "callback", 
         jsonpCallback: "YAHOO.Finance.SymbolSuggest.ssCallback", 
         data: { 
             query: "msft" 
         }, 
         url: "http://autoc.finance.yahoo.com/autoc" 
     }); 

     YAHOO.Finance.SymbolSuggest.ssCallback = function (data) { 
         alert(data.ResultSet.Result); 

         settings.beforeSend(settings); 

         settings.success(data.ResultSet.Result); 

         settings.complete('success'); 
     } 

 } 

});

/pre

Regards.

Return to “Issues”