Page 2 of 2

executing REST service from JS - how to synchronize

Posted: Tue Dec 17, 2013 7:45 pm
by Kartik A

I stringify the inside this and it printed following on console...

this value is inside success event : {"url":"https://api.appery.io/rest/1/db/colle...?
include=columnname&where=

This is what is going on.....

using 'this' outside is returning HTMLDivElement object and if we call 'this' inside success event its returning the RESTObject.

That tells us whats going wrong... we cannot use $(this).find inside success event.
Could you please advise what should I use inside success event to get access to current HTMLDivElement element.


executing REST service from JS - how to synchronize

Posted: Tue Dec 17, 2013 8:31 pm
by Kartik A

Thanks Katya for all your help!!! Finally Its working now.

Below are the steps to make it work.

Problem :-
The issue that we were facing was outside success event $(this) was referring to dom object [object HTMLDivElement] and inside success event it was referring to RESTService object[object Object]. We wanted inside success event access to [object HTMLDivElement] object.

Solution :-

Step 1 :

Code: Select all

Outside success event assign $(this) to some variable ex : thisHtmlJQObj  
var thisHtmlJQObj = $(this); 

Step 2 :

Code: Select all

Inside success event use the variable reference i.e thisHtmlJQObj to manipulate  dom. 

thisHtmlJQObj.find("div").find("a").html();     

:-)


executing REST service from JS - how to synchronize

Posted: Tue Dec 17, 2013 8:36 pm
by Kateryna Grynko

Kartik,

Glad it's working! Thank you for the update!