0

Using jquery AJAX to get data from a PHP script. The PHP script does some checking and will return html error codes like 403 or 400 when necessary. I would like to be able to set the reponseText to give a better description on the error for the 400 codes. Then allow my ajax fail function to handle it.

I have research the different PHP command, I'm not finding anything that will allow the reponseText to be set.

switch($table) {
    case "table1":      $tableID    = "table1";     $table  = "table1";     break;
    case "table2":      $tableID    = "table2";     $table  = "table2";     break;
    case "Table3":      $tableID    = "Table3";     $table  = "Table3";     break;
    case "Table4":      $tableID    = "Table4";     $table  = "Table4";     break;
    default:
        header('HTTP/1.0 400 Bad Request, missing information');
        $level = 'Information';
        $errorMessage = "[{$file}] [{$table}] table not found in list. line:".__LINE__;
        error_log($errorMessage);
        die();      
}

I would like the responseText to return "Table not found in list"

NealM
  • 58
  • 7

1 Answers1

1

The Die() command set the responseText. So changing the code to "die( 'Table not found in list' );" resolved the issue.

NealM
  • 58
  • 7