Kartik A
Posts: 0
Joined: Wed Nov 06, 2013 4:16 pm

executing REST service from JS - how to synchronize

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.

Kartik A
Posts: 0
Joined: Wed Nov 06, 2013 4:16 pm

executing REST service from JS - how to synchronize

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();     

:-)

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

executing REST service from JS - how to synchronize

Kartik,

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

Return to “Issues”