javascript - Disjunction of filters in ajax, request to flask-restless -
i have backend application flask-restless replies json data. set. request these data javascript $.ajax function. works perfect 1 filter, need more filters, don't know how them set.
example 1 filter (it works):
var page = 1; var filters = [{"name": "device", "op": "eq", "val": 1}]; var url = 'http://..../results?page=' + page; $.ajax({ url: url, data: {"q": json.stringify({"filters": filters})}, datatype: "jsonp", type: "get", contenttype: "application/jsonp", success: function(responsedata, textstatus, xmlhttprequest) {...} });
for 2 filters tried (it doesn't work):
var page = 1; var filters = [{"name": "device", "op": "eq", "val": 1},{"name": "device", "op": "eq", "val": 2}]; var url = 'http://..../results?page=' + page; $.ajax({ url: url, data: {"q": json.stringify({"filters": filters},{"disjunction":true})}, datatype: "jsonp", type: "get", contenttype: "application/jsonp", success: function(responsedata, textstatus, xmlhttprequest) {...} });
has of ever had similar problem?
you need give json.stringify array convert string.
data: {"q": json.stringify([{"filters": filters},{"disjunction":true}])},
Comments
Post a Comment