javascript parameter

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

javascript parameter

pierrick.bena
Hi everybody,

I would like to send a javascript parameter with this jQuery method :

$.ajax({

         url: "myurl",
         dataType: "json",
         data: {"myparameter" : "value"},
         beforeSend : function(xhr) {
         xhr.setRequestHeader("Authorization", "Basic " + coded);
         }

       })

Do you know how I could get the parameter "myparameter" back and use
its value in a velocity script ? I don't know if it's possible or not.

Thanks in advance for your help.

Regards, Pierrick

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: javascript parameter

Sergiu Dumitriu-3
On 05/27/2013 11:15 AM, [hidden email] wrote:

> Hi everybody,
>
> I would like to send a javascript parameter with this jQuery method :
>
> $.ajax({
>
>         url: "myurl",
>         dataType: "json",
>         data: {"myparameter" : "value"},
>         beforeSend : function(xhr) {
>         xhr.setRequestHeader("Authorization", "Basic " + coded);
>         }
>
>       })
>
> Do you know how I could get the parameter "myparameter" back and use its
> value in a velocity script ? I don't know if it's possible or not.

Sure, $request [1] exposes the request, which extends ServletRequest
which does have these methods:

$request.getParameter('myparameter') -> get one value
$request.getParameterValues('myparameter') -> get a list with all the values

[1]
http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=request&xpage=embed

> Thanks in advance for your help.
>
> Regards, Pierrick
>


--
Sergiu Dumitriu
http://purl.org/net/sergiu
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users