I created a page that receives a button from another page with jQuery AJAX but when I click on this button nothing happens. Code:
$(function () {
//$("#Menu ul li").click(function () { alert("ok"); });
$("a").button();
$("#Menu ul li:nth-child(2)").click(function () {
$("#ajaxLoader").fadeIn('slow');
$.ajax({
url: "CreateDataBase.htm",
type: "GET",
dataType: "html",
success: function (data) {
$("#ajaxLoader").fadeOut('slow');
$("#Sample").html("").append(data).css("textAlign", "center").css("paddingTop","30px") ;
$("a").button();
}
});
});
$("#Sample input:submit").click(function () { alert("Ok"); });
});
createdb page:
<a id="CreateDB">Create a Database</a>
I am also using jQuery UI. code in snipt.org
At the time your event is bound, the button isn’t there.
You want to either bind the event in the ajax-success-callback, or (better) use eventdelegation:
see http://api.jquery.com/on/ for details.