Re: [web2py] Web2Py and Ajax

2012-12-21 Thread Martijn Hermans
Thanks for your quick response.

Op vrijdag 21 december 2012 06:14:25 UTC+1 schreef rochacbruno het volgende:

 if not request.ajax:
 response.menu = _menu()

 On Thu, Dec 20, 2012 at 1:52 PM, Martijn Hermans 
 martijn...@gmail.comjavascript:
  wrote:

 When I handle a request in Web2Py it builds a menu in models/menu.py.
 This behaviour is exactly what I want for a normal request, but I want to 
 skip this, when I make an ajax-call.

 Is this possible?

 thx,

 Martijn

 -- 
  
  
  




-- 





[web2py] Web2Py and Ajax

2012-12-20 Thread Martijn Hermans
I've just started using web2py and have a question about ajax calls.

In my project a menu is defined (and build) in models/meny.py).
The menu is added to the response like this : response.menu = _menu()

In this way I can access the menu in my layout and that is exacly what I 
want, except...

when I am doing a ajax call. 

Is there a way to skip building my menu when I'm using a ajax call?



-- 





[web2py] Web2Py and Ajax

2012-12-20 Thread Martijn Hermans
When I handle a request in Web2Py it builds a menu in models/menu.py.
This behaviour is exactly what I want for a normal request, but I want to 
skip this, when I make an ajax-call.

Is this possible?

thx,

Martijn

-- 





Re: [web2py] Web2Py and Ajax

2012-12-20 Thread Bruno Rocha
if not request.ajax:
response.menu = _menu()

On Thu, Dec 20, 2012 at 1:52 PM, Martijn Hermans
martijn.herm...@gmail.comwrote:

 When I handle a request in Web2Py it builds a menu in models/menu.py.
 This behaviour is exactly what I want for a normal request, but I want to
 skip this, when I make an ajax-call.

 Is this possible?

 thx,

 Martijn

 --





-- 





[web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread PlanetUnknown
Trying to make a simple ajax call from the view back to the controller.
It is working, however the data I'm sending isn't coming in the 
request.vars if I sent the contentType=application/json.
I know there is an internal ajax function, but I have my own library with 
these functions I'd like to use.

Here is the code :
http://pastie.textmate.org/4670338 

Pretty sure I'm doing something silly here. Thanks.

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Bruno Rocha
Your URL should have the vars

url: /test01/default/getContent?sourcetitle=xxx

If you do not pass the vars on url you can't get them at the called
controller

-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Nik
Thanks Bruno !
That worked, but now when I get the response back as JSON, JQuery throws an 
error saying the JSON isn't valid. The JSON seems valid to me  also passes 
JSONLint test :

{readyState:4,responseText:FIFA support India for U-17 and 2022 World 
Cup - Times,status:200,statusText:OK} 



On Wednesday, 5 September 2012 17:40:42 UTC-4, rochacbruno wrote:

 Your URL should have the vars

 url: /test01/default/getContent?sourcetitle=xxx

 If you do not pass the vars on url you can't get them at the called 
 controller


-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Bruno Rocha
or you call it with .json extension and use the generic json view

url: /test01/default/getContent*.json*?sourceTitle=x

or you do this on the return

import json

def getContent():
titleArg = str(request.vars.sourceTitle)
print --
print --
print request.vars # Starts working if contentType in ajax request
above is commented
print Getting news content for :  + titleArg
print --
print --
#rows=db(db.NewsMaster).select(db.NewsMaster.ALL)


myobj = [dict(value=x),dict(value=x), dict(value=x)]
return json.dumps(myobj)



On Wed, Sep 5, 2012 at 6:51 PM, Nik nikhil.kodil...@gmail.com wrote:

 Thanks Bruno !
 That worked, but now when I get the response back as JSON, JQuery throws
 an error saying the JSON isn't valid. The JSON seems valid to me  also
 passes JSONLint test :

 {readyState:4,responseText:FIFA support India for U-17 and 2022 World
 Cup - Times,status:200,statusText:OK}



 On Wednesday, 5 September 2012 17:40:42 UTC-4, rochacbruno wrote:

 Your URL should have the vars

 url: /test01/default/getContent?**sourcetitle=xxx

 If you do not pass the vars on url you can't get them at the called
 controller

  --





-- 





Re: [web2py] Web2Py : JQuery .ajax data sent not present in request.vars

2012-09-05 Thread Nik
That worked too ! You rock :)

On Wednesday, 5 September 2012 17:58:16 UTC-4, rochacbruno wrote:

 or you call it with .json extension and use the generic json view

 url: /test01/default/getContent*.json*?sourceTitle=x

 or you do this on the return

 import json

 def getContent():
 titleArg = str(request.vars.sourceTitle)
 print --
 print --
 print request.vars # Starts working if contentType in ajax request 
 above is commented
 print Getting news content for :  + titleArg
 print --
 print --
 #rows=db(db.NewsMaster).select(db.NewsMaster.ALL)
 
 
 myobj = [dict(value=x),dict(value=x), dict(value=x)]
 return json.dumps(myobj)



 On Wed, Sep 5, 2012 at 6:51 PM, Nik nikhil@gmail.com javascript:wrote:

 Thanks Bruno !
 That worked, but now when I get the response back as JSON, JQuery throws 
 an error saying the JSON isn't valid. The JSON seems valid to me  also 
 passes JSONLint test :

 {readyState:4,responseText:FIFA support India for U-17 and 2022 
 World Cup - Times,status:200,statusText:OK} 



 On Wednesday, 5 September 2012 17:40:42 UTC-4, rochacbruno wrote:

 Your URL should have the vars

 url: /test01/default/getContent?**sourcetitle=xxx

 If you do not pass the vars on url you can't get them at the called 
 controller

  -- 
  
  
  





-- 





[web2py] web2py and ajax

2010-03-07 Thread mdipierro
http://gluonframework.wordpress.com/2010/03/07/web2py-ajax-and-forms/

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.