• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

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


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?
  • 2
1 Solution
Julian HansenCommented:
Can you show us some code?
is_numericAuthor Commented:
Code for sandbox...

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


Open in new window

Result page block for google cse

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


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
Julian HansenCommented:
It looks like you need to call this method on the CSE object


But I suspect to use it you need to code your search manually rather than just including the google script.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now