KAC Posted September 19, 2006 Report Share Posted September 19, 2006 es varbuut dariitu ko taadu - http://be.twixt.us/jquery/formSubmission.php Link to comment Share on other sites More sharing options...
Delfins Posted September 19, 2006 Report Share Posted September 19, 2006 Tāpat kā iepriekšējā piemērā: function validateForm(url,hForm) { // create request sendRPC(url,"callBackFunc",hForm); } function sendRPC(url,funcName,hForm) { ... xmlDoc = ... ... onreadystatechange() = function () { eval(funcName+"(xmlDoc,hForm)") } } Link to comment Share on other sites More sharing options...
andrisp Posted September 19, 2006 Author Report Share Posted September 19, 2006 Delfins, nesaprotu. Vai tad vienkārši nebūs tā, ka validateForm() izpildīs sendRPC() fju, un nosubmitēs formu, nemaz nesagaidot, kas notiks tālāk ? Link to comment Share on other sites More sharing options...
bubu Posted September 19, 2006 Report Share Posted September 19, 2006 Taisi sinhrono pierasījumu (kautgan visi jau tieši otrādi - taisa asinhronos pieprasījumus). open metodes trešais parametrs ko dara paskaties (true/false). Link to comment Share on other sites More sharing options...
andrisp Posted September 19, 2006 Author Report Share Posted September 19, 2006 o, tas jau izskatās pēc tā ko vēlos.. Link to comment Share on other sites More sharing options...
Delfins Posted September 19, 2006 Report Share Posted September 19, 2006 Nu var gan syn/asyn... Asyn-metodē pēc sekmīgas validācijas taisam POST + validācijas f-jai jāatgriež false, ja nepieciešams - un protams, to visu var panākt ar parametru padošanu function validateForm(...,doPost?) { // do asyn-xml-request ... return false; } function formValidateCallback(xmlDoc,hForm,doPost) { if (xmlDoc.responseText == "" && doPost) { hForm.post(); } } Link to comment Share on other sites More sharing options...
andrisp Posted September 19, 2006 Author Report Share Posted September 19, 2006 Nočakarējos ilgi un dikti, un beigās nonācu pie šāda koda, kas pat vairs nav Ajax, bet ir tieši tas, kas man vajadzīgs. function newXMLDoc() { var xmlDoc = null; if (window.XMLHttpRequest) { xmlDoc = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE try { xmlDoc = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlDoc = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } return xmlDoc; } function requestPage( queryString) { var xmlDoc = newXMLDoc(); if (typeof(xmlDoc) != 'object') return false; xmlDoc.open( "GET", queryString, false ); xmlDoc.send(null); if (xmlDoc.status == 200) { return xmlDoc.responseText; } else { return false; } } function check_form(form) { var x = requestPage('test.txt'); } Link to comment Share on other sites More sharing options...
Orion7 Posted September 20, 2006 Report Share Posted September 20, 2006 es varbuut dariitu ko taadu - http://be.twixt.us/jquery/formSubmission.php Tad nu gan baigi labā forma, es visur savadīju aaaaaaa, epasta adresi ieskaitot, un man rāda: «Success, you submitted the form.»... Link to comment Share on other sites More sharing options...
john.brown Posted September 21, 2006 Report Share Posted September 21, 2006 Mīļumiņ, bet tu ar lasīji, kas tur pirms tās formiņas bija rakstīts? I've disabled the db lookup, but test@example.com should provide a "Email Address already used" error. Tak tas ir tik piemērs, kā taisīt ajax, nevis smalka formas validācija ;) Link to comment Share on other sites More sharing options...
Recommended Posts