User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 362,344 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,781 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

ajax server-returned message?

Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation: MattEvans will become famous soon enough MattEvans will become famous soon enough 
Rep Power: 4
Solved Threads: 45
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: ajax server-returned message?

  #7  
Nov 28th, 2007
So does this mean i have to return other http status code manually incase i catch an exception?

That's what I would do; if PHP doesn't abort with true HTTP errors, then catch every possible error at the PHP level, set a 4xx or 5xx error status code and respond the error message, otherwise set a 200 status ( its the default so you dont have to do anything ) and respond a 'success' message or whatever else it is that you want to respond with on success.

I forgot to mention, if using headers manually; you must set the status and header before responding any other content - this might mean you have to buffer output until you're sure that the response is error free, or decide very quickly whether the response is an error or not. Also, you'd have to mark en entire response as either an error or a success, so, you wouldn't be able to mix error messages with success messages.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
All times are GMT -4. The time now is 11:12 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC