jQuery. ... wait until 3rd party call has finished

Hi

I have a page calling a Google search engine result set. I want to target specific elements from the result set using jQuery but the call happens after the page has loaded. When I use the document.ready method the call has not returned the results I need at that time so my JQuery returns null.

How can I pause the JQuery function until the results come in from the web service?
is_numericAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Can you show us some code?
0
is_numericAuthor Commented:
Code for sandbox...

querystring to results page (change the q value to search param)

?q=sofa

Open in new window


Result page block for google cse

<script>
    
  $(function() {
    var cx = '016407060398575523151:h2hqysivcfo';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
    
  });

</script>
<gcse:searchresults-only></gcse:searchresults-only>

Open in new window


The results are returned into the DOM and NOT by IFRAME

Looking to clone the pagination block and add to top of resultset
0
Julian HansenCommented:
It looks like you need to call this method on the CSE object

setSearchCompleteCallback

But I suspect to use it you need to code your search manually rather than just including the google script.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.