I have developed a site on my local machine and got it working fine, but after uploading it to my remote host, the ajax/json calls fail to run.
I have checked for any html being written before the redirects are run and the only things I can find are where I am echoing json_encode($return).
Is this the problem? And if so does anyone know how I can fix this.? An alternative to using echo maybe??
thanks
Code below with labels as to where I think the problem might be...
<script type="text/javascript">
$(document).ready( function() {
$("#addStory input[type=submit]").click(function(e) {
e.preventDefault();
$.post('editor.php', $("#addStory").serialize(), function(result) {
alert(result.adminList);
}, "json");
});
});
</script>
<form name="addStory" action="" method="post" id="addStory">
<input type="text" id="test_text" name="test_text" />
<input type="submit" value="Submit" />
</form>
And here's editor.php...
<?php
header('application/json');
$return = array();
$return['adminList'] = "Hello World!";
echo json_encode($return);
?>
The "Hello World" alert does not happen...
header('location: ...)call? I don't see it in your code.