简体   繁体   中英

Ajax call no error but does not work

Here my Ajax Call and it does not produce any error but it does not call the php file (I can see it in the network tab of my chrome, and when I call it in the javascript console, it's does return false as expected :

 function submitData() {
    $('#sortable2').sortable({
        axis: 'y',
        update: function(event, ui) {
            var data = $(this).sortable('serialize');
            $.ajax({
                data: data,
                type: 'POST',
                url: './post_occupation_data.php'
            });
        }
    });
    return false;
}

Thank you

Try this code and and check the if you are getting alert messages are not.. if 404 alert message please check your URL

  function submitData() {
    $('#sortable2').sortable({
        axis: 'y',
        update: function(event, ui) {
            var data = $(this).sortable('serialize');
            $.ajax({
                data: data,
                type: 'POST',
                url: './post_occupation_data.php',
                error: function (xhr, ajaxOptions, thrownError) {
                       alert(xhr.status);
                      alert(thrownError);
                      },
              success: function(result){
                    alert(result);
                  }
            });
        }
    });
    return false;
}

try to stringify the parameter like below

data: JSON.stringify(data)

Also add below parameters in your ajax call

contentType: "application/json; charset=utf-8",
dataType: "json",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM