Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax Form submission in Google App Engine with jQuery
    primarykey
    data
    text
    <p>could not figure out why it is not working:</p> <p>i need to send request to server, generate some fragment of html in python with meanCal method, and then want that fragment embedded into submitting html file using calculation method and dynamically shows in dyContent div. all the processes are done by single click on submit button in a form. </p> <p>any suggestions??? thanks in advance.</p> <p><strong>the submitting html:</strong></p> <pre><code>&lt;div id="dyContent" style="height: 200px;"&gt; waiting for user... {{ mgs }} &lt;/div&gt; &lt;div id="leturetext"&gt; &lt;form id="mean" method="post" action="/calculation"&gt; &lt;select name="meanselect"&gt; &lt;option value=10&gt;example&lt;/option&gt; &lt;option value=11&gt;exercise&lt;/option&gt; &lt;/select&gt; &lt;input type="button" name="btnMean" value="Check Results" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { //$("#btnMean").live("click", function() { $("#mean").submit(function(){ $.ajax({ type: "POST", cache: false, url: "/meanCal", success: function(html) { $("#dyContent").html(html); } }); return false; }); }); &lt;/script&gt; </code></pre> <p><strong>python:</strong></p> <pre><code>class MainHandler(webapp.RequestHandler): def get(self): path = self.request.path if doRender(self, path): return doRender(self,'index.htm') class calculationHandler(webapp.RequestHandler): def post(self): doRender(self, 'Diagnostic_stats.htm', {'mgs' : "refreshed.", }) def get(self): doRender(self, 'Diagnostic_stats.htm') class meanHandler(webapp.RequestHandler): def get(self): global GL index = self.request.get('meanselect'.value) if (index == 10): allData = GL.exampleData dataString = ','.join(map(str, allData)) dataMean = (str)(stats.lmean(allData)) doRender(self, 'Result.htm', { 'dataIn' : dataString, 'MEAN' : "Example Mean is: " + dataMean, }) return else: allData = GL.exerciseData dataString = ','.join(map(str, allData)) dataMean = (str)(stats.lmean(allData)) doRender(self, 'Result.htm', { 'dataIn' : dataString, 'MEAN' : "Exercise Mean is: " + dataMean, }) def main(): global GL GL = GlobalVariables() application = webapp.WSGIApplication( [('/calculation', calculationHandler), ('/meanCal', meanHandler), ('.*', MainHandler), ], debug=True) wsgiref.handlers.CGIHandler().run(application) if __name__ == '__main__': main() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload