[Grok-dev] Ajax-problem with grok

Christian Klinger cklinger at novareto.de
Tue Jan 17 13:04:44 UTC 2012


Hi Marcel,

how does your "ajax-url" looks if you request your render method?
It must be something like: 
XXX/set_invocide?form.project.group=bla&form.project.item=bla
Is this correct. What happes if you add this url directly in your 
browser, does the validation work?

In my projects i use jquery and grok.JSON for my dynamic ajax stuff.
It works smoothly. If you wish i can provide you an example.

HTH
Christian

MarcelK schrieb:
> I got a problem within grok when I try to use a Ajax http-request.
>
> This is what I do:
>
> 1. I have a render method on a view class called "set_invoice"
> 2. I have a form where I can choose "project" (form.project.group)&
> "subroject (form.project.item)"
> 3. Once subproject is choosen, a onChange Event triggers the function
> below.
> 4. Within my render method, a validation is performed which return
> True or
> False,
> depending on the values of "form.project.group" and "form.project.item"
> 5. This is where my problem begins: Within my render method, I dont
> have the
> values of group& item (project& subproject) on my request, like I
> expected in
> the old Zope2 days.
>
> QUESTION: How can I pass those field-values to the python method? It
> seems
> to be impossible
> to pass them via url-params or via request, sicne the request
> (self.request.form) within my
> python-method remains empty no matter I try to change it.
>
> below the function Project_fkt() that is called with onChange + the
> doGet:
>
> ......
> this.doGet = function(params) {
> // make a HTTP GET request to the URL asynchronously
> req.open("POST", url, true);
> //Send the proper header information along with the request
> req.setRequestHeader("Content-type",
> "application/x-www-form-urlencoded");
> req.setRequestHeader("Content-length", params.length);
> req.setRequestHeader("Connection", "close");
> req.send(params);
> }
> }
> ......
>
> function Project_fkt(item) {
> var url = './set_invoice'
> var ajax = new AJAXInteraction(url, validateCallback);
> var params = 'form.project.group=' +
> document.getElementsByName('form.project.group')[0].value; +
> '&form.project.item=' + item.value;
> ajax.doGet(params);
> }
> ....
>
> --
> View this message in context:
> http://python.6.n6.nabble.com/Ajax-problem-with-grok-tp3680518p3680518.html
>
> Sent from the Grok mailing list archive at Nabble.com.



More information about the Grok-dev mailing list