Jump to content

URL control in Ajax


supertwister

Recommended Posts

Hi All,I'm developing a basic website and have a question. Hope it's not too much basic. I'm new in web stuff.I have the following code:

$.ajax({url: '/blabla/yadayada'type: "get",success:function(data, testStatus, jqXHR){.........},error: function(jqXHR, testStatus, errorThrown){alert('error')}});

In addition, i have the following Python code:

class AfCont(object):def __init__(self, target, context):self.target_server = targetself.context = contextself.baseContext = "/MyApp%s" % ( ("-" + self.context) if self.context else "")print "Starting %s with server: %s " % (self, self.target_server)def general_url(self, url_sfx):headers = {"Accept": "application/json"}params = Nonethe_url = "%s/%s" % (self.baseContext, url_sfx)print "%s %s %s " % (self, self.target_server, the_url)conn = httplib.HTTPConnection(self.target_server, "8080")conn.request("GET", the_url, params, headers)response = conn.getresponse()theResp = response.read()return theResp@cherrypy.exposedef bla_yada(self):htmlText = self.general_url("blabla/yadayada")return htmlText

As you can see in the Ajax code, my URL is /blabla/yadayada. However, i need to send GET requests to /blabla/yadayada/number. I want to control the number part with a parameter. For example:

number = 150 -- > `/blabla/yadayada/150`number = 9595-- > `/blabla/yadayada/9595`

Can someone help me with that? Hope i was clear enough.

Edited by supertwister
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...