i have a simple ajax script that sends 3 variables to an external php script, it then adds them into an array and sends the array back, and i want it to output it in the javascript console, so that i can check that the variables are being passed back successfully, however when i run the script nothing appears in the console, only that
XHR finished loading: "http://localhost/blank/scripts/ajax/profile_password_submit.php".
Here is the ajax
$("#pro_content_password").submit(function() {
var url = "scripts/ajax/profile_password_submit.php"; // the script where you handle the form input.
var js_array=new Array();
$.ajax({
type: "POST",
url: url,
data: $("#pro_content_password").serialize(), // serializes the form's elements.
success: function(data){
js_array=data;
console.log(js_array);
},
dataType: 'json'
});
return false; // avoid to execute the actual submit of the form.
});
Here is the external php script
session_start();
include '../../connect.php';
$user_id = "";
$user_id = $_SESSION['userId'];
echo $user_id;
if(empty($_SESSION['userId'])){
echo "user id session not set";
exit;
}
$old_password = $_POST['pro_content_password_old'];
$new_password = $_POST['pro_content_password_new'];
$new_password1 = $_POST['pro_content_password_verify'];
$password_array = array("old"=>$old_password,"new"=>$new_password, "new1"=>$new_password1);
echo json_encode($password_array);
Any ideas? Also i am using Google Chrome console