Thxs I updated my page and precise the source (you :-) )
http://extensions.xwiki.org/xwiki/bin/view/Extension/AJAX+example
I thinks this page is better in developpment section, no?
Because it is not a usefull extension, except to explain/show a nice ajax example in
Xwiki.
WDYT?
--------------------------------------------
En date de : Mer 25.3.15, Marius Dumitru Florea <mariusdumitru.florea(a)xwiki.com> a
écrit :
Objet: [xwiki-users] Fwd: Fw : Fw : Re: ajax example
À: "XWiki Users" <users(a)xwiki.org>
Date: Mercredi 25 mars 2015, 9h50
---------- Forwarded
message ----------
From: Marius Dumitru
Florea <mariusdumitru.florea(a)xwiki.com>
Date: Wed, Mar 25, 2015 at 10:49 AM
Subject: Re: Fw : [xwiki-users] Fw : Re: ajax
example
To: Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>
On Tue, Mar
24, 2015 at 7:34 PM, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>
wrote:
> >
For step 1: Don't print
> >
the JSON directly. You'll have
escaping
> > issues. In order to ensure the
generated JSON
> > is valid you
should
> > build the JSON in
memory
> > (using Velocity/Java
maps, arrays and
basic
> > types)
and then serialize it:
> >
>> > $jsontool.serialize({
>>
> "greeting":
"Hello",
"location": "World"
> > })
> I agree but one* purpose was to use
Vincent example on
pages?
Anyway, do
you prefer this code?
{{velocity wiki="false"}}
## If AJAX call
#if("$!request.outputSyntax" != '')
$response.setContentType('application/json')
#end
#set($MyJsonData
= {'greeting': 'Hello', 'location':
'World'})
$jsontool.serialize($MyJsonData)
> {{/velocity}}
Definitely.
Thanks,
Marius
>>
>>
> >
>> > For
step 4:
> > Don't hard-code
the page URL and
use the 'get'
instead of 'view' to
avoid
> > adding view statistics
entries.
> >
>> > var url = new
> >
XWiki.Document('JsonHello',
'Sandbox').getURL('get');
> Thxs I was
too lazy to take too
long time to find JS
>> function. :-)
>>
> >
>> > Also, to avoid the need
to
>> > URL-encode the request parameters
you
> > should
> > pass them using an object not a
string.
> >
>> > var params = {
>>
> >
'xpage': 'plain',
>>
>> > 'outputSyntax':
'plain'
> > };
> > $.get(url, params,
> > function(data) {
> > ...
> > });
>
> Yes thxs you
>
=> I uploaded/update my page
>>
>> (The worst is that I hate JS) :-)
>>
>>
>>
>> Pascal B
>>
> >
>> > Hope this
>> > helps,
>>
> Marius
>>
> >
>> > On
Fri, Mar 20, 2015 at 8:26 PM, Pascal BASTIEN
>> > <pbasnews-xwiki(a)yahoo.fr>
>> > wrote:
>>
> > Hello,
>> >
>> > >
Here, I provided an simple
Ajax example to
> > use in xwiki
application:
validate that
> > what I wrote is
the best way (like
suggest Vincent)
>>
>
>> > > Thxs.
>> >
>>
> > Pascal
>> > BASTIEN
>> >
>>
>
> >
_______________________________________________
>> > > users mailing list
>> > > users(a)xwiki.org
>> > >
http://lists.xwiki.org/mailman/listinfo/users
> >
>>
_______________________________________________
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users