Use `$.ajax` for better error handling

Use `error` option of `$.ajax` to handle php callback errors (e.g. `403 Forbidden`, `404 Not Found`, etc.)