I have a popup which upon hoover requests data from the server to display. The only way I could prevent multiple popups, however, was to use synchronous ajax. I understand that synchronous ajax should rarely if never be used. Can this be done asynchronously? I am just learning about callbacks are needed, and have a feeling they are related. Thanks
(function( $ ){
$.fn.screenshotPreview = function() {
xOffset = 20;
yOffset = 10;
this.hover(function(e) {
$.ajax({
url: 'getPopup.php',
success: function(data)
{
$("body").append('<div id="screenshot">dl><dt>Name:</dt><dd>'+data.name+'</dd><dt>User Name:</dt><dd>'+data.username+'</dd></dl></div>');
$("#screenshot")
.css("top",(e.pageY - yOffset) + "px")
.css("left",(e.pageX + xOffset) + "px")
.fadeIn("fast");
},
async: false,
dataType: 'json'
});
},
function() {
$("#screenshot").remove();
});
this.mousemove(function(e) {
$("#screenshot").css("top",(e.pageY - yOffset) + "px").css("left",(e.pageX + xOffset) + "px");
});
};
})( jQuery );