I am using an AJAX pagination and that is working fine.
It returns the data succesfully. e.g:-
if (xmlHttp.readyState==4)
{
document.getElementById("NewsFeedListID").innerHTML=xmlHttp.responseText;
}
Now NewsFeedListID div contains the correct data.
Now I have to use jQuery on that response AJAX page, but jQuery is not working.
Can anyone help?
Reading your explanation in the comments section of your question I believe Josh has hit upon the answer.
The reason your jQuery event is not working is because, you "attach" the event handlers using $('#delete').click(function() {alert('success');})
to the anchor/button with id "delete" (that's the #delete part), then later that anchor "#delete" get's removed from the DOM when you replace the innerHTML of "#NewsFeedListID", so you would either have to re-attach the event handlers to #delete, or as Josh has suggested use a technique known as event delegation to keep the click event triggering even though you are replacing the innerHTML.
I'll leave it to you to look into "event delegation" and using jQuery to simplify your ajax requests (look into the method "load" for a very simple alternative to what you are describing) but use $('#delete').live('click',function() {alert('success');})
to solve your immediate problem.
Your best bet is to include jQuery in the original page, not the AJAX request, then use .live()
to bind the event. This will bind the event to the element whether or not it is included on the page. Then when you insert the element via AJAX, your button will work.
What I understand is that you are having the JS code in the returned page, which doesnt work, and It wont work because setting the innerHTML doesnt execute the JS in it, it just places HTML code there, to execute the JS code here you will have to eval the code after you insert it in the page.
Eval is never a good idea, I would suggest you to have all your JS code in original page, and use .live() function of jquery to attach events to elements that arent present on your page when its loaded.