Non Brazilian Non Brazilian - 2 years ago 92
PHP Question

Jquery send post form ajax not work

am try to send form ajax like this code

<script type='text/javascript'>
/* attach a submit handler to the form */
$("#non").submit(function(event) {

/* stop form from submitting normally */

/* get some values from elements on the page: */
var $form = $( this ),
url = $form.attr( 'action' );

/* Send the data using post */
var posting = $.post( url, { title: $('#mak').val(),meaning: $('#za').val()} );

/* Alerts the results */
posting.done(function( data ) {

it not alert success,and i check action after click button is ok

Answer Source

If jquery.min.js added. Then please ignore it. Else add it. To get action of <form> Use var action_url = form.attr('action');

<script src=""></script>
$('#non').on('submit', function(e) {
    var form = $(this);
    var formData = form.serialize();
    var action_url = form.attr('action');
      url: action_url,
      type: "POST",
      data: formData,
      success: function (data) {
      error: function () {
        alert("Oops..!! Problem Ocurred. Please Try Again..!!");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download