Re: [Proto-Scripty] ajax call
If you are creating the form in the page after it loads, the observer has to be created after the form, in order to bind to that DOM object. The way around this is to use the on() function to register a deferred listener. I am on my phone, so I can't test this, but try this: document.on('submit', '#myform', function(evt, elm){ //your code here }); Walter On Jul 22, 2013, at 10:54 AM, Agnese Camellini agnese.camell...@gmail.com wrote: Hello, i'm writing a form which i have to process in javascript (ajax). The problem is i probably read too many manuals online and offline so i have a bit of confusion in mind i should sort out some way. The thing is that my form is generated by a json file (i'm using Tornado, so i'm reading the json file in python and passing it to the web page when rendered to build the form). Now the form has to be processed by an ajax function and this is where it gets tricky for me. i'm pasting the code written for now, there are two type of ajax call written and i haven't tried to see if it work cause i'm not undestanding what to do, so i've only tried to fill the variables written in the examples online tring to undestand how it works. The code is here below: html head meta http-equiv=Content-Type content=text/html; charset=utf-8/ link rel='stylesheet' type='text/css' href='/static/style.css'/ script var lin={% raw line %} function str_to_obj(o){ document.write('bodydiv id=up-bar/divdiv id=logoimg class=logo src=/static/logo-admantx.png alt=logo/divform id=myform action=/myform/ method=post') document.write('div id=myFormContainer') for(item in o.Form) { document.write(o.Form[item].Description + ' brhrbr'); for(i in o.Form[item].Response){ document.write('label for=' + o.Form[item].Response[i].Name + ''); document.write('input type=radio name=message' + item +' value=' + o.Form[item].Response[i].Name + '' + o.Form[item].Response[i].Name + '/labelbr'); }; }; document.write('input type=submit value=Submit/div/form') }; str_to_obj(lin); /script script type=text/javascript src=/static/prototype.js/script script _ # First example Event.observe('myform', 'submit', function(event) { $('myform').request({ onFailure: function() { },#what should i write here? onSuccess: function(t) { $('myAdmantContainer').update(t.responseText);#where should i set responseText? } }); Event.stop(event); // stop the form from submitting }); #second example function chiam-ajax() { var url = '/myform/'; var pars = document.forms[0].message0.value + '' + document.forms[0].message1.value ; var target = 'myAdmantContainer'; var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars}); }; /headdiv id=myAdmantContainer/div/body/html Does anyone have a vague idea of what to do? Agnese -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To unsubscribe from this group and stop receiving emails from it, send an email to prototype-scriptaculous+unsubscr...@googlegroups.com. To post to this group, send email to prototype-scriptaculous@googlegroups.com. Visit this group at http://groups.google.com/group/prototype-scriptaculous. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To unsubscribe from this group and stop receiving emails from it, send an email to prototype-scriptaculous+unsubscr...@googlegroups.com. To post to this group, send email to prototype-scriptaculous@googlegroups.com. Visit this group at http://groups.google.com/group/prototype-scriptaculous. For more options, visit https://groups.google.com/groups/opt_out.
[Proto-Scripty] ajax call
Hello, i'm writing a form which i have to process in javascript (ajax). The problem is i probably read too many manuals online and offline so i have a bit of confusion in mind i should sort out some way. The thing is that my form is generated by a json file (i'm using Tornado, so i'm reading the json file in python and passing it to the web page when rendered to build the form). Now the form has to be processed by an ajax function and this is where it gets tricky for me. i'm pasting the code written for now, there are two type of ajax call written and i haven't tried to see if it work cause i'm not undestanding what to do, so i've only tried to fill the variables written in the examples online tring to undestand how it works. The code is here below: html head meta http-equiv=Content-Type content=text/html; charset=utf-8/ link rel='stylesheet' type='text/css' href='/static/style.css'/ script var lin={% raw line %} function str_to_obj(o){ document.write('bodydiv id=up-bar/divdiv id=logoimg class=logo src=/static/logo-admantx.png alt=logo/divform id=myform action=/myform/ method=post') document.write('div id=myFormContainer') for(item in o.Form) { document.write(o.Form[item].Description + ' brhrbr'); for(i in o.Form[item].Response){ document.write('label for=' + o.Form[item].Response[i].Name + ''); document.write('input type=radio name=message' + item +' value=' + o.Form[item].Response[i].Name + '' + o.Form[item].Response[i].Name + '/labelbr'); }; }; document.write('input type=submit value=Submit/div/form') }; str_to_obj(lin); /script script type=text/javascript src=/static/prototype.js/script script _ # First example Event.observe('myform', 'submit', function(event) { $('myform').request({ onFailure: function() { },#what should i write here? onSuccess: function(t) { $('myAdmantContainer').update(t.responseText);#where should i set responseText? } }); Event.stop(event); // stop the form from submitting }); #second example function chiam-ajax() { var url = '/myform/'; var pars = document.forms[0].message0.value + '' + document.forms[0].message1.value ; var target = 'myAdmantContainer'; var myAjax = new Ajax.Updater(target, url, {method: 'post', parameters: pars}); }; /headdiv id=myAdmantContainer/div/body/html Does anyone have a vague idea of what to do? Agnese -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To unsubscribe from this group and stop receiving emails from it, send an email to prototype-scriptaculous+unsubscr...@googlegroups.com. To post to this group, send email to prototype-scriptaculous@googlegroups.com. Visit this group at http://groups.google.com/group/prototype-scriptaculous. For more options, visit https://groups.google.com/groups/opt_out.
[Proto-Scripty] Ajax Call waits callback forever
Hello there ! It's been a (little) year since I've started using prototype.js. It's really great and it simplifies my dev life a lot ! I use it to develop a chat application (www.kraml.fr) and I use the PeriodicalUpdater to retrieve the new events. But, somehow, it happens that the call never retrieves the answer from the server, even if in Apache log I see that the page has been called by that user. For now, I try to escape the problem by putting a timeout on the call (from a script found on the web), but to avoid loosing information, I have to send a receipt, which is slowing my app, and is not really reliable as it can pend as the periodical call. I don't think it comes from the prototype library, but I thought people could have had an idea or even had the same problem. I'm looking actually at the PHP sessions, but am not really sure it has something to do with it. Thanks in advance, Regards, Julien. (tyrsensei on www.kraml.fr if you want to test on live) -- 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] Ajax call is not working in MAC(Firefox)
I have a script which executes periodically after each 10 seconds. You can see that there is an ajax call which actually updates database for me and return 1 or 0 depending of the script execution. The problem is, it is working cool in windows platform with firefox 3.0.11. But not working with the same version of firefox in MAC OS. The Script: new PeriodicalExecuter(function(){ var date = new Date(); //console.log('setOnlineStatus.php?sid='+date.getTime()); new Ajax.Request('setOnlineStatus.php?sid='+date.getTime(), {method:'get', onComplete:function(transport){ if(!parseInt(transport.responseText)) window.location=../index.php; }}); },10); Can anybody has any idea about this? Thanks in advance for your help. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---