Hi All,
I have a script which is fairly short, it simply saves the submission to a database and then returns.
Near the top i had
Everything worked.
At the bottom i was returning a string, either telling me it was success or failure.
Now i am calling this script with AJAX and no matter what happens that sees a successful status and thinks there was no problem.
I have now removed the header for the content type instead in my output at the bottom putting the following code;-
All i am getting now is premature end of script headers.
I have gone through and there are no calls to print anything before the end of the script. There is no output from the script atall.
If someone could give a little bit of background to how to send non-ok status codes that would be great, i am finding the documentation and web searches only say to add a "content-type" at the top of the script...
thanks.
jez
I have a script which is fairly short, it simply saves the submission to a database and then returns.
Near the top i had
Code:
print "Content-type: text/html\n\n";
Everything worked.
At the bottom i was returning a string, either telling me it was success or failure.
Now i am calling this script with AJAX and no matter what happens that sees a successful status and thinks there was no problem.
I have now removed the header for the content type instead in my output at the bottom putting the following code;-
Code:
if($sth->errstr) {
print $query->header('text/html','204 No response');
}else{
print "Content-type: text/html\n\n";
print "Record stored for ".$session_id ." on local db";
}
All i am getting now is premature end of script headers.
I have gone through and there are no calls to print anything before the end of the script. There is no output from the script atall.
If someone could give a little bit of background to how to send non-ok status codes that would be great, i am finding the documentation and web searches only say to add a "content-type" at the top of the script...
thanks.
jez