Handling Ajax Call

Hamed Zarei <[email protected]>
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
Hello everybody!
I wanna integrate datatables.js and cherrypy; but can't handle multiple 
data in ajax call( something like: data:{"d1":1, "d2": 2,...})
So I decide to simplify the problem and just working with ajax call in 
cherrypy
HTML Code:
<input type="text" id="inp1">
<input type="text" id="inp2">
<input type="button" value="submit">

jQuery Code:
$(document).ready(function(){
$('input').click(function(){
$.ajax({
url: '/web',
type: 'GET',
data: {"inp1": $('#inp1').val()},
success: function (data) {
console.log(data);
}
}).done(function(){
alert('done');
}).fail(function(){
alert('fail')
});
});
});

CherryPy Code:
class String(object):
@cherrypy.expose
def index(self):
return open('client.html')

class Web(object):
exposed = True
    
@cherrypy.tools.accept(media='text/plain')
def GET(self, inp1):
return inp1
def POST(self):
return 'post'
def PUT(self):
return 'PUT'
if __name__ == '__main__':
conf = {
'/': {
   'tools.sessions.on': True,
   'tools.staticdir.root': os.path.abspath(os.getcwd())
},
'/web': {
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
'tools.response_headers.on': True,
            'tools.response_headers.headers': [('Content-Type', 
'text/plain')]
} 
}
webapp = String()
webapp.web = Web()
cherrypy.quickstart(webapp, '/', conf)


I'm Confused alot, Please Help me to do the best!

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.