Randy Webb wrote:
> jshanman said the following on 1/30/2006 3:01 PM:
> > amerar@iwc.net wrote:
> >> Hi All,
> >>
> >> I have a form that uses Javascript to validate some fields. Whe the
> >> user selects to submit the form with certain values selected, I want to
> >> be able to execute a Perl script, query the MySQL database to get my
> >> resuts and return an ALERT box to the user if his form input was
> >> invalid.
> >>
> >> Problem is, I do not want to change the screen. I just want the dialog
> >> to pop up. I am very good at Perl, but I'm less than a novice at
> >> Javascript. I was hoping that if someone had an exmple of this, they
> >> could put it up and explain it to me........
> >>
> >> Thanks,
> >>
> >> Arthur
> >
> >
> > You would need to use XmlHTTPRequest to send all the form fields to a
> > perl page that can check the input against the database/validation
> > functions, and either return OK to submit, or return false for a
> > particular field name/number. This is also known as AJAX.
> > http://www.w3schools.com/xml/xml_http.asp
>
> Why do people continue to make the mistake of thinking that
> XMLHTTPRequest is the only way to do that? It's not. It is also not the
> most widely supported way of doing it. One simple solution that comes to
> mind is to submit a dummy form in a hidden IFrame and read the results
> back from there.
>
> --
> Randy
> comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
> Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Your right, its not the only way. Another way is outline in the
article linked below, which involved appending a child script that is
generated by a server page. The author claims that this is more
compatible then XmlHTTPRequest, however, it only supports GET requests.
Interesting technique, at least.
http://www.phpit.net/article/ajax-php-without-xmlhttprequest/
Received on Tue Feb 7 21:28:45 2006