0

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?

4
  • 1
    And the error would be..? Commented Aug 31, 2013 at 16:08
  • it doesn t load anything Commented Aug 31, 2013 at 16:09
  • 1
    Any errors in your browser console? What version of jQuery are you using? .live() was removed in 1.9, superceded by .on(). Commented Aug 31, 2013 at 16:10
  • im running jQuery 1.7 Commented Aug 31, 2013 at 16:13

3 Answers 3

2

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);
})
Sign up to request clarification or add additional context in comments.

Comments

1

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:

Api Jquery method On

Comments

0

Do this instead:

$('#go').click(function (){
 sssssss(page);
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.