I'm having problems with losing focus on the page when returning HTML using AJAX calls with jQuery. This results in two clicks being required to use any of the injected links. Using .focus() on the returned elements doesn't appear to have an effect. I solved a similar problem previously (that resulted in buttons needing to be clicked twice) by using prependTo but this doesn't seem to work in this instance. Any help would be greatly appreciated.
Cheers.
$('input#5000').click(function(){
//Run SQL query
$
$.ajax({
type: 'POST',
url: '/querytorun/',
data: 'querytorun='+$('p#3000').html(),
//Either display error message or results
error: function(){ $('p#4000').html("Can't run SQL query"); },
success: function(data) {
$('p#4000').html(data);
$('div').remove('.qbb');
$('<div class = qbb><input id="email_btn" type="button" onClick="window.location=\'email_form_list/\'" value="Email Users" /></div>').prependTo('#export_query_wrapper');
开发者_C百科 $('<div class = qbb><input id="csv_btn" type="button" onClick="window.location=\'csv_export/\'" value="Export CSV" /></div>').prependTo('#export_query_wrapper');
}
});
return false;
});
精彩评论