You can do:
jQuery.ajax({
type: "POST",
url: url,
data: JSON.stringify(data),
success: callback,
dataType: "json",
contentType: APPLICATION_JSON,
processData: false
}).then(......);
On Monday, 16 June 2014 16:17:57 UTC-5, chuan137 wrote:
>
> Dear all,
>
> In my javascript code, I would like to have sth like this,
>
> $.getJSON(url_to_REST_api, {
> group: 0,
> sensors: sensorIDs
> }, function(res) {
> timestamp = res['timestamp'];
> data = res['data'];
> });
>
> However, sensorIDs is a rather long array, which in turn generate a
> request url very ugly, like this
>
>>
>> http://localhost:8000/service/test/katrin?group=0&sensors%5B%5D=2&sensors%5B%5D=3&sensors%5B%5D=4&sensors%5B%5D=5&sensors%5B%5D=6&sensors%5B%5D=7&sensors%5B%5D=8&sensors%5B%5D=9&sensors%5B%5D=74&sensors%5B%5D=66&sensors%5B%5D=68&sensors%5B%5D=99&sensors%5B%5D=75&sensors%5B%5D=67&sensors%5B%5D=69&sensors%5B%5D=100&sensors%5B%5D=102&sensors%5B%5D=106&sensors%5B%5D=107&sensors%5B%5D=108&sensors%5B%5D=149&sensors%5B%5D=150&sensors%5B%5D=103&sensors%5B%5D=109&sensors%5B%5D=110&sensors%5B%5D=111&sensors%5B%5D=151&sensors%5B%5D=152&sensors%5B%5D=59&sensors%5B%5D=61&sensors%5B%5D=75&sensors%5B%5D=78&sensors%5B%5D=80&sensors%5B%5D=82&sensors%5B%5D=145&sensors%5B%5D=112&sensors%5B%5D=113&sensors%5B%5D=116&sensors%5B%5D=117&sensors%5B%5D=118&sensors%5B%5D=146&sensors%5B%5D=119&sensors%5B%5D=120&sensors%5B%5D=123&sensors%5B%5D=124&sensors%5B%5D=125&sensors%5B%5D=186&sensors%5B%5D=187&sensors%5B%5D=188&sensors%5B%5D=190&sensors%5B%5D=191&sensors%5B%5D=192&sensors%5B%5D=180&sensors%5B%5D=181&sensors%5B%5D=182&sensors%5B%5D=183&sensors%5B%5D=184&sensors%5B%5D=185
>
>
> What best strategy should I take? Change the $.getJSON() to Post and Get?
> (I am not sure how to do it yet) And how to design my api?
>
> Thanks in advance.
>
> Chuan
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.