I am writing Greasemonkey Script for pages in this site (Site1). Site1 has offers and offers of various kinds, and my GM Script aims to do the following:
When you visit the offer on Site1, Script asks Site2 to find out if this hotel is listed on Site2. If so, display the search results from Site2 on Site 1.
The problem is that Site2 displays a progress bar ("Download Results") and then displays the results. So my Ajax request always returns empty results and looks like this (see Reddish part):
(Click to enlarge)
However, in fact, it should have the full content of the search results from site2, for example:
(Click to enlarge)
I tried synchronous Ajax request as well as GM_xmlhttpRequest
no avail.
This is a problematic progress indicator on site 2:
(Click to enlarge)
How can I make an AJAX request wait for a search on Site2 to be fully displayed before returning a response to Site1?
For reference, my full working Script code is on pastebin.com .
This is the corresponding snippet:
$(document).ready(function(){ var rewardsSiteResults = $('<div class="panel deal-panel rc-lr"></div>').attr('id', "rewardsSiteResults") .html("<p>" + progressMessageText + "</p> ").append(spinnerGif); $(insertSelector).after(rewardsSiteResults); var addressMap = getAddressOfHotel(); var pinCode = addressMap[pinCodePlaceHolder]; var hotelName = addressMap[hotelNamePlaceHolder]; var queryURL = constructQueryURL(pinCode, hotelName); $.ajaxSetup({async:true, timeout: 5000}); $.get(queryURL,null, function(response) { if(!displayed){ displayed=true;
source share