goldiman
goldiman

Reputation: 187

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

Upvotes: 2

Views: 1943

Answers (2)

Rakesh Sajja
Rakesh Sajja

Reputation: 148

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",

Upvotes: 0

Sai Kumar
Sai Kumar

Reputation: 328

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;
}

Upvotes: 2

Related Questions