I have a php page with the follow javascript code in it:
$("#saveButton").click(function() {
HLalert('Saving...');
$.getJSON("<?php echo $PHP_SELF; ?>", {
ajax: 1,
classes: $("#alllessons").serialize()
}, function(output) {
if (output.status == false) { HLalert(output.message); }
else { HLalert('Saved!.'); }
});
});
For whatever real it does not work. The javascript before and after it exectute but these seemingly does not. Not even a failed status is returned.
HLalert() is a function that displays a twitter like alert message.
At the top of the php page I have the code
<?php
if ($_GET['ajax'] == 1) {
// parse the ajax values
// output json and die
}
// regular page code
I tried changing the names of the passed values in the getJSON call, that doesn’t do anything. I’ve tried putting the page the getJSON calls into a different file and that doesn’t do anything either.
Is there something fundamentally wrong with my getJSON code that I just cannot see? Are you allowed to make $.ajax calls to your self-page?
Thanks
do you mean
$_SERVER['PHP_SELF']? I am not really sure if there is a$PHP_SELF.