Page 2 of 2

Reponse area one item error

Posted: Sun Dec 14, 2014 6:07 pm
by Ihor Didevych

Hi Hnto,

We are sorry that you had trouble with this issue. We will try to find workaround.


Reponse area one item error

Posted: Mon Dec 15, 2014 9:45 pm
by Evgene Karachevtsev

Hello Hnto,

As Yurii mentioned in the link below
1) This is one of approaches:
prevar onSuccess = function(data){
alert("serviceresponse");
//Using response.
};
serviceName.execute({success: onSuccess});/pre
With this code you get the data from response, but you need to make your own mapping.

2) The other way is to parse xml with use of jQuery
http://api.jquery.com/jquery.parsexml/

3) The last and more efficient way is to:
a) get xml
b) add library https://code.google.com/p/x2js/ to your app
c) launch javascript with used of imported library and parse all to json
d) create Generic REST Service that will return generated json
After this step you will get your normal mapping


Reponse area one item error

Posted: Sun Aug 02, 2015 2:53 pm
by Hein

Found this on the docs, however it'd be better if these methods can be written in more details. I have to idea when you mean 'launch javascript', and from where? etc...


Reponse area one item error

Posted: Tue Aug 04, 2015 2:37 am
by Yurii Orishchuk

Hi Hein,

Here is workaround for this problem:

  1. Add to your service datasource "success" "javascript" event handler before mapping.
    Details: http://prntscr.com/615h4s/direct

  2. Populate this javascript with following JS code:
    Details: http://prntscr.com/615ik7/direct

    pre

    //Where "note.tag" is path to your response array. You should replace this part with yours.
    data.note.tag = _.isArray(data.note.tag) ? data.note.tag : [data.note.tag];

    /pre

    See example of how to get "note.tag" in the code: http://prntscr.com/615j9q/direct
    So you should open your success mapping and find "path" to your array and replace with this part "note.tag"

    Regards.