views:

81

answers:

2

Big picture question. I've got a cherrypy server running with all the shopping cart methods for my e-commerce site written in python. I'm working with jquery on the front end.

POSTing to my python methods is easy in javascript, but not passing data the other way. I can send it back with JSON, but not always conveniently. It seems like the easiest way is to just create javascript variables with cheetah like var width = $width but that seems messy.

What am I doing fundamentally wrong here? It doesn't seem like I'm structuring my server-client interaction correctly at all. What's the best way to have my server methods called, and what's the best way to embed information from the server into a page so that it can be worked on with javascript?

A: 

As far as I know what you're talking about here can be done in two ways that I know.

  1. AJAX requests can return whatever you want.
  2. Multiple posting to pages and logic that changes the pages(views)

If you're talking at a lower level, you can get some information in the http request about your newly connected client.

I'm not really sure what all you're asking here. Could you give a more specific example?

Thomas Schultz
Once a product is picked, then the site redirects to a customization page. It's easy to dynamically generate that page with cheetah, but how does the javascript in that page know which product was picked (or whatever other data it needs)?Then, once the product is customized, should I:a) make an ajax call to an addProduct() method exposed on the cherrypy server when the "finished" link is clicked on the customization page?b) link to an exposed method in a form on the customization page which calls addProduct() and then redirects to the shopping cart?c) something else?
colinmarc