I have this jquery autocomplete code.Everything works fine data is loaded etc.Success is working.But when i have error...error handling is not working in below code.
 $("#autocomplete").on("filterablebeforefilter", function (e, data) {
      if (value && value.length > 0) {
        //$ul.listview("refresh");
             $('.ui-responsive-panel').enhanceWithin();
             $.ajax({
                       type: "GET",
                       url: "http://domain.com/food.php",
                       dataType: "jsonp",
                       crossDomain: true,
                       data: $(this).serialize(),
                       success: function (data) {
                            alert("success");
                       },
                       error: function () {
                             alert("an error occurred!");
                       },
                       beforeSend: function () {
                            // This callback function will trigger before data is sent
                       },
                       complete: function () {
                            setTimeout(function () {}, 1);
                       }
                     })
                     .then(function (response) {
                             $.each(response, function (i, val) {
                                 //do something with data
                             });
                         }
                 });
 
     
     
     
    