I'm using jQuery and Codeigniter to update the database via AJAX. The following code does not seem to do anything or send anything to my controller when the button is clicked...
jQuery:
$("#button_submit1").click(function(e) { $.ajax({ type: "POST", url: window.location.href, dataType: "json", data: $('#writereview_form').serialize() + '&ajax=true', cache: false, success: function(data) { alert("yay"); //$("#writereview_box").fadeOut(1000); } }); return false; }); HTML:
<form action="http://mysite.com/places/writereview/2107" id="writereview_form" method="post" accept-charset="utf-8"> ... ... <input type="submit" name="submit" value="Submit Review" class="button_submit" id="button_submit1"> Any ideas why the ajax data is not being sent?
return falsewill prevent the defaultsubmit. My suspect would bewindow.location.href. Do you see the XHR request in chrome's dev tools?