I have a page in which I have a div. The content from that div is being populated by an includes page, and that includes page is making a call to a database to retrieve content
change this line
$(".newtask").click(function(){
to
$(document).on(".newtask","click",function(){
or use delegate
$(document).delegate("click",".newtask",function(){
reason is the dynamically added elements do not get themselves attached to event handlers use on if you are using jQuery 1.7+ else use delegate