RE: How to handle the server response?

Daniel,

It's certainly possible to get access to the instance via script, and then
to do anything you like with it. However, since the model you are copying
from your AJAX version simply retrieves an error string from the returned
DOM and then puts it into a div, I would certainly recommend that you use
@replace="instance" with an xf:output, as you have suggested. That way you
don't need any script at all, since the whole wiring is done for you. If
your server reports more than one error at a time, then just use a
xf:repeat, a nice side-effect of which is that if there are no errors then
the xf:repeat will just render nothing.

One other thing worth considering is, if you have control over the server
code it might be worth returning an HTTP error code along with your XML.
This will be picked up by the XForms processor and give you an
xforms-submit-error, rather than an xforms-submit-done.

Regards,

Mark


Mark Birbeck
CEO
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
w: http://www.formsPlayer.com/
b: http://internet-apps.blogspot.com/

Download our XForms processor from
http://www.formsPlayer.com/ 

> -----Original Message-----
> From: www-forms-request@w3.org 
> [mailto:www-forms-request@w3.org] On Behalf Of Daniel Swarbrick
> Sent: 25 September 2005 11:10
> To: www-forms@w3.org
> Subject: How to handle the server response?
> 
> 
> Is it possible to interpret the server response in Javascript 
> from a server response after xforms-submit-done?
> 
> My intention is to submit data (with replace=none) to a PHP 
> script that attempts to insert a record into a database. 
> However, if there is a database primary key violation, this 
> needs to be reported to the xforms client, and an appropriate 
> error displayed.
> 
> Or am I better to use some "output" tags in my document, and 
> set replace=instance and instance=my-output-instance to 
> display anything returned from the server upon submit?
> 
> I currently achieve this functionality with Ajax, using 
> Javascript to parse a small XML document returned by the 
> server containing server-side validation failure errors, and 
> writeln() them to a div.
> 
> 
> 

Received on Monday, 26 September 2005 09:28:24 UTC