The error parameter in jQuery ajax methods refers to errors caused by a bad connection, timeout, wrong URL, such things. This is not the mistake you are thinking about.
What most people do is something like this ...
Php
if ($group_id == 0) { echo json_encode(array( 'status' => 'error', 'message'=> 'error message' )); } else { echo json_encode(array( 'status' => 'success', 'message'=> 'success message' )); }
Javascript
$(document).ready(function(){ $('#postride').submit(function(event) { event.preventDefault(); dataString = $("#postride").serialize(); $.ajax({ type: "post", url: "postride.php", dataType:"json", data: dataString, success: function (response) { if(response.status === "success") {
source share