I have this function which run when loading the page
function sssssss(page){
loading_show();
$.ajax
({
type: "GET",
url: "load_data.php",
data: "page="+page,
success: function(msg)
{
$("#container").ajaxComplete(function(event, request, settings)
{
loading_hide();
$("#container").html(msg);
});
}
});
}
I need to call this function also onClick let's say when clicking button id="go" I have tried by adding
$('#go').live('click',function sssssss(page){... }
it gives me an error.
How to call this function on Click?
Try this,
$('#go').live('click', function () {
sssssss(page);
})
As of jQuery 1.7, the .live()
method is deprecated. Use .on()
to attach event handlers.
You should use,
$('body').on('click', '#go', function () {
sssssss(page);
})
API of Jquery says: As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers.
this should work:
$('#go').on('click', sssssss(page));
You can see examples here:
Do this instead:
$('#go').click(function (){
sssssss(page);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.