[Proto-Scripty] Re: forms - serialize and more
Hi Quleczka All your suggestions look good and probably are great technique for getting this done. BUT, no matter what I do, no matter ghow I code this - and I have now tried at least a dozen different ways, I get the exact same problem - as soon as I address my form, I get an error - either firefox says the form has no properties or it just hangs at the place where I address (serialize, do form request, etc) the form. If I take AJAX out, and just let normal submission occur, correct processing occurs and I can reload the original page in its entirety (redirect). Normal AJAX Updater processing works, but as soon as I use a form... boom!!! I am at my wits end - I could experiment with doing this right aka some of your suggestions (and BTW - at first there was no 'good' response, just attempt to do what you suggest - load 'MiddleContent' directly from the form processor - but no form is working here. Could there possibly be some other conflict with jQuery or ??? Thanks for your suggestions tho. Ben On Mar 9, 3:14 pm, Quleczka qulec...@gazeta.pl wrote: Hi, First of all I'm not prototype expert, rather newbie ;) 1) why do you use onsubmit=validatethis(); if you can use $ ('formlinks').observe('submit',validatethis); 2) you don't have to set asynchronous:true - it's default value 3) most common is parameters: $('formlinks').serialize(true) than using postBody 4) use parameters: { dept: $F('dept'), reg: $F('reg') } instead of this long postBody:'dept='+department+'reg='+region ...this looks really bad !!! ;) you can also try to use $('formname').serializeElements( elements selection go here) for example $('formname').getInputs('text') which selects all input textfields from the same form or something similar ...you can use Element.select() or $$() if these elements have something in common (like class, type etc.) - any group of elements can go into serializeElements() 5) where do you use mlprerresult variable? cause there is quite big chance that you don't have this variable set by ajax request cause before loadMenu() is called 6) as far as I understand logic of this app it would be better to call loadmenu(); inside reportresult(); than it's sure it is called only after success of ajax request 7) can't you get this data from 'site/traderhomecenter.php' or 'site/ adminhomecenter.php in response of first ajax request already? are the values $F('mlptrader'); $F('mlpdepartment'); etc. from form 'formlinks'? if yes... you passed it all to the server already in first ajax request ... so can't you make one more php file which will calls 'Admin/editmylinks2' inside and instead of returning just 'good' returns result of traderhomecenter.php or adminhomecenter.pl? or just change editmylinks2 to return this? you can send good if you want is x-json header of the same ajax response and in the body you can send html which you want to use to update MiddleContent' simple example of php -- $response = array ('good'=true); header('X-JSON: ('.json_encode($response).')'); if ($_POST('mlptrader')) die (variable with html you get from traderhomecenter); else die (variable with html you get from adminhomecenter); and then in javascript function reportresult(transport) { var good = transport.headerJSON.good; if (good){ document.getElementById(mlprerresult).innerHTML = 'Your request completed successfully'; //instead of ajax updater just update $('Middle Contect').innerHTML here with what you have in transport.responseText }else document.getElementById(mlprerresult).innerHTML = 'Your request failed!!!'; - These are my thought to make it easier but I'm not sure I understand correctly logic of your application. Quleczka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: forms - serialize and more
For the first time something is happening - though I am not sure what. Explorer is hanging up after giving a 'null' response for the alert below - but, firefox is not even hitting the alert and is processing normally, thogh it does not have the code to complete the AJAX request, just redirects to redo the original page. Can someone please tell me what is going on form method=post id=formlinks name=formlinks action=Admin/ editmylinks2.php onsubmit=$('formlinks').observe ('submit',validatethis); validatethis = function() { submitOK=true; sometests... if (((text1.length 1 url1.length 0) || (text1.length 0 url1.length 1)) || ((text2.length 1 url2.length 0) || (text2.length 0 url2.length 1)) || ((text3.length 1 url3.length 0) || (text3.length 0 url3.length 1))){ alert(If you enter link text, you must enter a URL and vice- versa); submitOK = false; } if (submitOK == false){ return false; } else { loadingScreen('MiddleContent','Loading...'); // working for IE; firefox not getting here - is taking different route to process code postIt('formlinks'); } } function postIt(theform) { var form = $(theform); alert (form); // as said, firfox not goingt here, but IE reports 'null' for this alert form.request({ onComplete: function() { alert ('good') } }) } (I assume Firefox is just going directly to action of form, but do not know why) Ben On Mar 10, 10:04 am, Bhudda Ben benjamin.rud...@gmail.com wrote: Hi Quleczka All your suggestions look good and probably are great technique for getting this done. BUT, no matter what I do, no matter ghow I code this - and I have now tried at least a dozen different ways, I get the exact same problem - as soon as I address my form, I get an error - either firefox says the form has no properties or it just hangs at the place where I address (serialize, do form request, etc) the form. If I take AJAX out, and just let normal submission occur, correct processing occurs and I can reload the original page in its entirety (redirect). Normal AJAX Updater processing works, but as soon as I use a form... boom!!! I am at my wits end - I could experiment with doing this right aka some of your suggestions (and BTW - at first there was no 'good' response, just attempt to do what you suggest - load 'MiddleContent' directly from the form processor - but no form is working here. Could there possibly be some other conflict with jQuery or ??? Thanks for your suggestions tho. Ben On Mar 9, 3:14 pm, Quleczka qulec...@gazeta.pl wrote: Hi, First of all I'm not prototype expert, rather newbie ;) 1) why do you use onsubmit=validatethis(); if you can use $ ('formlinks').observe('submit',validatethis); 2) you don't have to set asynchronous:true - it's default value 3) most common is parameters: $('formlinks').serialize(true) than using postBody 4) use parameters: { dept: $F('dept'), reg: $F('reg') } instead of this long postBody:'dept='+department+'reg='+region ...this looks really bad !!! ;) you can also try to use $('formname').serializeElements( elements selection go here) for example $('formname').getInputs('text') which selects all input textfields from the same form or something similar ...you can use Element.select() or $$() if these elements have something in common (like class, type etc.) - any group of elements can go into serializeElements() 5) where do you use mlprerresult variable? cause there is quite big chance that you don't have this variable set by ajax request cause before loadMenu() is called 6) as far as I understand logic of this app it would be better to call loadmenu(); inside reportresult(); than it's sure it is called only after success of ajax request 7) can't you get this data from 'site/traderhomecenter.php' or 'site/ adminhomecenter.php in response of first ajax request already? are the values $F('mlptrader'); $F('mlpdepartment'); etc. from form 'formlinks'? if yes... you passed it all to the server already in first ajax request ... so can't you make one more php file which will calls 'Admin/editmylinks2' inside and instead of returning just 'good' returns result of traderhomecenter.php or adminhomecenter.pl? or just change editmylinks2 to return this? you can send good if you want is x-json header of the same ajax response and in the body you can send html which you want to use to update MiddleContent' simple example of php -- $response = array ('good'=true); header('X-JSON: ('.json_encode($response).')'); if ($_POST('mlptrader')) die (variable with html you get from traderhomecenter); else die (variable with html you get from adminhomecenter); and then in javascript
[Proto-Scripty] Re: forms - serialize and more
Explorer is hanging up after giving a 'null' response for the alert below - but, firefox is not even hitting the alert and is processing normally, thogh it does not have the code to complete the AJAX request, just redirects to redo the original page If you don't use event.stop() for is just submitted without waiting for anything from ajax... you have mess in your code... I fixed it and posted here http://pastie.org/413066 it is working now :) you don't use observe in onSubmit...it is pointless :) as soon as I address my form, I get an error - either firefox says the form has no properties or it just hangs at the place where I address No one can't help you with this serializing problem without some simplified working example of your form. By the way are you using firebug to debug this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: forms - serialize and more
as additional info, I should mention: there are multiple forms - tho with much different names jQuery is also loaded which at first gave me conflicts, but Ajax.Updater, at least, working now the form giving me problem is itself loaded via Ajax.Updater - along with (using eval) the script 'validatethis' (and others, which seem to be working) ... On Mar 9, 12:09 pm, Bhudda Ben benjamin.rud...@gmail.com wrote: Hi I have a rather large complicated form that changes considerably based on database content and user interaction - therefore, I said to myself, I need to serialize ?? The whole is I wish to serialize form elements, pass them to php (Admin/editmylinks2.php) - which would update database (working) and then write the word 'good' back to page which would be processed by (reportresult) and then the loadmenu function would bring content to my div 'MiddleContent'. My current problem is with the serialization process - I am getting 'form formlinks has no properties' error in FireFox errorconsole. But I also want to ask about my technique in general - the serialize form followed by AjaxRequest followed by loadmenu function which calls Ajax.Updater... form method=post id=formlinks name=formlinks action=Admin/ editmylinks2.php onsubmit=validatethis(); validatethis = function() // this function arrives through AJAX with the form, that seems OK; other functions (loadmenu, reportresult, loadingScreen) arrive with original page { // bunch of error checking here which if there are errors makes submitOK = false if (submitOK == false){ return false; } else { loadingScreen('MiddleContent','Loading...'); var parms = $('formlinks').serialize(true); new Ajax.Request('Admin/editmylinks2.php', {asynchronous:true, postBody:parms, onSuccess:reportresult}); loadmenu(); } } function reportresult(transport) { var response = transport.responseText; if (response == 'good') document.getElementById(mlprerresult).innerHTML = 'Your request completed successfully'; else document.getElementById(mlprerresult).innerHTML = 'Your request failed!!!'; } function loadMenu() { var trader = $F('mlptrader'); var department = $F('mlpdepartment'); var region = $F('mlpregion'); var office = $F('mlpoffice'); var user = $F('mlpuser'); var jack = 'Y'; loadingScreen('MiddleContent','Loading Navigation'); if (trader) { new Ajax.Updater('MiddleContent', 'site/traderhomecenter.php', {asynchronous:true, postBody:'dept='+department+'reg='+region +'off='+office+'user='+user+'jack='+jack, onlyLatestOfClass: 'Ajax.Updater'}); } else { new Ajax.Updater('MiddleContent', 'site/adminhomecenter.php', {asynchronous:true, postBody:'dept='+department+'reg='+region +'off='+office+'user='+user+'jack='+jack, onlyLatestOfClass: 'Ajax.Updater'}); } } All help greatly appreciated --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: forms - serialize and more
Hi, First of all I'm not prototype expert, rather newbie ;) 1) why do you use onsubmit=validatethis(); if you can use $ ('formlinks').observe('submit',validatethis); 2) you don't have to set asynchronous:true - it's default value 3) most common is parameters: $('formlinks').serialize(true) than using postBody 4) use parameters: { dept: $F('dept'), reg: $F('reg') } instead of this long postBody:'dept='+department+'reg='+region ...this looks really bad !!! ;) you can also try to use $('formname').serializeElements( elements selection go here) for example $('formname').getInputs('text') which selects all input textfields from the same form or something similar ...you can use Element.select() or $$() if these elements have something in common (like class, type etc.) - any group of elements can go into serializeElements() 5) where do you use mlprerresult variable? cause there is quite big chance that you don't have this variable set by ajax request cause before loadMenu() is called 6) as far as I understand logic of this app it would be better to call loadmenu(); inside reportresult(); than it's sure it is called only after success of ajax request 7) can't you get this data from 'site/traderhomecenter.php' or 'site/ adminhomecenter.php in response of first ajax request already? are the values $F('mlptrader'); $F('mlpdepartment'); etc. from form 'formlinks'? if yes... you passed it all to the server already in first ajax request ... so can't you make one more php file which will calls 'Admin/editmylinks2' inside and instead of returning just 'good' returns result of traderhomecenter.php or adminhomecenter.pl? or just change editmylinks2 to return this? you can send good if you want is x-json header of the same ajax response and in the body you can send html which you want to use to update MiddleContent' simple example of php -- $response = array ('good'=true); header('X-JSON: ('.json_encode($response).')'); if ($_POST('mlptrader')) die (variable with html you get from traderhomecenter); else die (variable with html you get from adminhomecenter); and then in javascript function reportresult(transport) { var good = transport.headerJSON.good; if (good){ document.getElementById(mlprerresult).innerHTML = 'Your request completed successfully'; //instead of ajax updater just update $('Middle Contect').innerHTML here with what you have in transport.responseText }else document.getElementById(mlprerresult).innerHTML = 'Your request failed!!!'; - These are my thought to make it easier but I'm not sure I understand correctly logic of your application. Quleczka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---