I want to use Greasemonkey to display more information at the site menu. the new information should show how many orders/items are behind the menuelinks.
e.g. New Orders (1) Proofed Orders (20)
I tried this code:
//NEW
var pageInhalt = getTheImportant('http://example.com/orders.php?s=NEW&');
if (pageInhalt.indexOf('from ') > 0) {
var amount = pageInhalt.substring( pageInhalt.indexOf('from ')+4, pageInhalt.indexOf('</td>', pageInhalt.indexOf('from ')+5));
$( "#div01" ).find( "li:contains('NEW')" ).append(' (' + amount + ') ');
}
else { $( "#div01" ).find( "li:contains('NEW')" ).append(' (0) '); }
function getTheImportant(url) {
var result;
$.ajax({
type: "GET",
url: url,
async: false,
success: function(data) {
result = data;
}
});
return result;
}
But now the source has changed from a static table to a dynamic table. My problem is that the dynamic part will load the information I need - the amount of orders/items.
so my $.ajax
isn't working anymore.
I know that I can use waitForKeyElements
and I also use this succsessfull with an other script but without $.ajax
call.
How can I tell $.ajax
to wait for a key element?
Rolled in from OP's response, below:
The site with the table is behind a login. But I can show an example which looks similar:
datatables.net/examples/styling/jqueryUI.html
There you can see 'Showing 31 to 40 of 57 entries'.
The number 57 would be the information I need.
One this page with the table I use Greasemonkey in this way:
function makeAction (jNode) {
//find the number of entries an do somthing with the result
$(this).find....
}
waitForKeyElements (".odd", makeAction);
But I need a little bit help how I can get this information by a link (the menuelink) using AJAX.
If I use AJAX I will get only the source code without the dynamic part - the Table. So my conclusion was I should use waitForKeyElements
with AJAX?