2

I'm just trying to make a simple ajax call on click of a button to pass some data from a textbox using ajax and retrieve the same after ajax call.But some thing is messy in here causin an alert without any data

Here is my ajaxTest.html

    <html>

    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"
        type="text/javascript">

        </script>
        <script>
            function getData() {
                var vdata = $('#txt').val();
                $.ajax({
                    type: "GET",
                    url: "/processAjax",
                    data: vdata,
                    success: function (responseText) {
                        alert(responseText);
                    }
                });
            }
        </script>
    </head>

    <body>
        <input id="txt" type="textbox" runat="server" />
        <input type="button" runat="server" onclick="getData();" />
    </body>

</html>

Here is my main.py

import httplib2
import os

class AjaxCall(webapp.RequestHandler):
  def get(self):
    template_data = {}
    template_path = 'ajaxTest.html'
    self.response.out.write(template.render(template_path,template_data))

class ProcessAjax(webapp.RequestHandler):
  def get(self):
    inputdata = self.request.get("inputData")
    self.response.out.write(inputdata)


application = webapp.WSGIApplication(
                                     [('/processAjax',ProcessAjax),
                      ('/ajaxPage',AjaxCall)
                                    ],
                                     debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

1 Answer 1

2

Your AJAX call doesn't include a inputData query field at all. Update your jQuery $.ajax() data parameter:

data: { inputData: vdata },
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.