The problem I have is that my alert box is coming up and displaying my php script instead of the echo'd variable results.
HTML/Javascript
Code: Select all
<html>
<head>
<title> json and php test</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript">
$(function(){
var data = {"variable1":"data1"};
$.post("getJSON.php",data,function(rdata){alert(rdata);},"text");
});
</script>
</head>
<body>
</body>
</html>
PHP Script
Code: Select all
<?php
$res = json_decode($_POST['variable1'], true);
header("Content-type: text/plain");
$ret = "done";
echo $ret;
?>
Thanks
Bryce