So I’m trying to make a little userscript to send data to a server and react to the answer (by manipulating the link I added to the site)
jQuery('table.borderlist').after('<a href="#" id="action"><Click here to do derp</a><br />');
This works and adds the link to the site now I bind my new element to a click handler using live() (because that seems to be the only way to work with my new link (id=action))
It looks something like this:
jQuery('#action').live('click', function() {
jQuery.ajax({
type: 'GET',
dataType: 'jsonp',
data: 'id=666',
jsonp: 'jsonp_callback',
url: 'url',
success: function (j) {
// in here I want to change the element with id=action but nothing I tried so far seems to work
}});});
the basic idea is to do something like this:
jQuery('#action').replaceWith('Action successful');
problem is that this does not seem to work on elements I’ve just created using the Greasemonkey Script on any other element it works fine.
Appreciate any hints in the right direction
Ok I have soved it now the problem was that the site uses more than one table with class borderlist 2 of them not visible -.-‘ so that I could not see that the script actually worked … Now I selected only the right Element and its working like a charm.
Thanks for your help anyways.