Ich habe diese Ajax-Anforderung:Php ist das Hinzufügen Fehler/Hinweis Protokoll Ajax-Request Antwort
$.ajax({
type: 'POST',
url: 'contactUsInsertBoat.php',
data: {
name: $insertBoatForm.find('input[name=name]').val(),
phone: $insertBoatForm.find('input[name=phone]').val(),
email: $insertBoatForm.find('input[name=email]').val(),
},
success:function(data){
// successful request;
var json_obj=JSON.parse(data);
var $insertBoatContent = $('#insert-boat-content');
$insertBoatContent.addClass("center");
if (json_obj["response"] == true) {
$insertBoatContent.html("<br/><h4>Richiesta inviata con successo</h4>");
} else {
$insertBoatContent.html("<br/><h4>Richiesta non inviata</h4>");
}
},
error:function(){
// failed request; give feedback to user
$('#ajax-panel').html('<p class="error"><strong>Oops!</strong> Try that again in a few moments.</p>');
}
});
In "contactUsInsertBoat.php" Ich tue dies:
include 'functions.php';
require_once 'BusinessLogic/Manager.php';
use BusinessLogic\Manager;
sec_session_start();
if(isset($_POST['name'])){
Manager::contactInsertBoats($_POST['name'],$_POST['email'],$_POST['phone']);
$arrResult = array ('response'=>true);
echo json_encode($arrResult);
}else{
$arrResult = array ('response'=>false);
echo json_encode($arrResult);
}
Aber danach habe ich dies tun Firebug Konsole schreibt:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
var json_obj=JSON.parse(data);
und der Inhalt des JSON ist:
<br />
<b>Strict Standards</b>: Non-static method BusinessLogic\Manager::sendMail() should not be called statically in <b>/var/www/public/BusinessLogic/Manager.php</b> on line <b>1957</b><br />
{"response":true}
Warum wird dem JSON-Objekt das strikte Standardprotokoll hinzugefügt?
Es ist wie der Fehler sagt, Sie rufen 'sendMail()' als statische Methode und es ist nicht. Das Problem liegt in Ihrer Manager.php-Datei. – TheDrot
@TheDrot Vielleicht war ich nicht klar genug: Ich verstehe nicht, warum diese Nachricht in die Antwort des JSON obj. Es ist jedoch kein Fehler: Es ist nur eine "Strict Standards" Nachricht, die die Ausführung nicht blockiert – Finn87
Nun fügen Sie 'ini_set ('display_errors', '0');' oben um Fehler zu verstecken. Aber ich denke, du solltest diese Dinge reparieren. – TheDrot