Browser JSONP AJAX Requests

Everything pertaining to the data.sparkfun.com service, the phant project which powers it, and user projects which talk to the service.

Moderators: phalanx, toddtreece, Brennen@SparkFun

Post Reply
eephillip
Posts: 4
Joined: Thu Oct 07, 2010 8:58 am

Browser JSONP AJAX Requests

Post by eephillip » Sun Mar 15, 2015 6:20 pm

How does one format the ajax JSONP object to do a filter on the timestamp.
Maybe the answer is you can't only support for URL encoding?

The following is from here
https://github.com/sparkfun/phant/issues/98
Date range query string example (in UTC):

Code: Select all

?gt[timestamp]=2014-08-15&lt[timestamp]=2014-08-20

Code: Select all

?gt[timestamp]=now -2 months&lt[timestamp]=now -1 month
day(s), week(s), month(s) and year(s) are supported

Trying to do somthing like the following.

Code: Select all

var jsonData = $.ajax({
        url: 'https://data.sparkfun.com/output/' + public_key + '.json',
        // data: {page: 5},
        // gt : now -2 hours',
        // 'gt[timestamp]' : 'now -1 hour',
        'lte' : ['timestamp', 'now - 2 hour'],     
        dataType: 'jsonp',
})

eephillip
Posts: 4
Joined: Thu Oct 07, 2010 8:58 am

Re: Browser JSONP AJAX Requests

Post by eephillip » Sun Mar 15, 2015 9:33 pm

Just figured it out, you have to place the filter in the data tag.

Code: Select all

data : {'gte' : {'timestamp' : 'now - 1 hours'}}

rullywowr
Posts: 3
Joined: Wed Sep 04, 2013 5:48 am

Re: Browser JSONP AJAX Requests

Post by rullywowr » Fri Mar 20, 2015 10:27 am

L

agilb
Posts: 12
Joined: Wed Apr 11, 2012 8:23 am
Location: Utah, USA

Re: Browser JSONP AJAX Requests

Post by agilb » Mon May 18, 2015 1:33 pm

Thanks! That helped.

Post Reply