I was having the same problem, it turns out that applying the scroll on the outer div was causing the problem. In your case, applying scroll on 'MyDiv' is the issue. Instead of applying scroll on 'MyDiv', you should have a div in the html returned from the ajax call, and apply scroll on that div.
var out = '';
var dv = $('#Mydiv');
$.ajax({
url: url,
type: 'POST',
data:{pg:pg},
error: function() {
return;
},
dataType: 'html',
success: function(data) {
if(data.trim() !=='ERROR'){
//Here the html in data.trim() should have an enclosing div like
out = data.trim();
dv.append(out);
}
},
complete:function(v){
/NOT WORK//
//Don't apply scroll on dv
//dv.ace_scroll({inline_style:true,size: 200,observeContent:true, mouseWheelLock: true});
//Apply scroll on the inner div
$('#MyScrollDiv').ace_scroll({inline_style:true,size: 200,observeContent:true, mouseWheelLock: true});
}
});