I have written this code to call a php function from javascript, the php function simply prints the arguments it receives, but this code is giving no output and nothing is printed, I am using google chrome browser, kindly help.
index.html file
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
jQuery.ajax(
{
type: "POST",
url: 'save.php',
dataType: 'json',
data: {functionname:'saveUser', arguments:["username", "password"]},
success: function (obj, textstatus) {
if( !('error' in obj) ) {
alert(obj.result);
}
else {
console.log(obj.error);
}
}
});
</script>
</head>
</html>
save.php file
<?php
header('Content-Type: application/json');
if( $_POST['functionname'] == 'saveUser' ) {
echo json_encode(Array(
result => $_POST['arguments'][0] . ' ' . $_POST['arguments'][1]
));
}
?>

functionnamedeclared which you are sending via POST method?error_reporting(E_ALL); ini_set('display_errors', 1);Ctrl+U?