Tag: jsonp

使用开始和结束时间之间的时间过滤数组或XML

我有一个API调用。 该调用返回XML,我将XML转换为数组,然后使用json_encode在jsonp调用中发回响应。 我正在做的是工作,但API不允许我按状态过滤,按开始和结束时间过滤,并确保房间可用。 几个jsponp调用让它变得疯狂。 再一次,我所拥有的是工作,但我需要找到一种方法来再次过滤我的结果。 我已经返回了正确的状态和正确的日期,但我仍然需要过滤掉时间。 如果时间目前是上午10点29分,我不想显示从上午10点30分开始预订的房间,因为直到上午10:30才预订。 因此,如果我当前的时间是上午10:29,我需要过滤我的数组中的事件,并且只显示具有当前时间的开始和结束时间的事件。 从上午10点到11点的预订应该留在我的arrays中,但是从下午2-4点开始的预订不应该出现在我的arrays中。 正如我所说,数组首先是一个返回的XML文档,然后是一个数组,然后是JSON,所以从技术上讲,我可以使用任何可以过滤的工作。 PHP以XML格式过滤,PHP过滤数组。 甚至Javascript也可以通过我的ajax调用来准备PHP文件。 在我将其转换为JSON并返回之前,这是我的数组。 我过滤的时间应该是TimeEventStart和TimeEventEnd。 我可以使用当前的Javascript时间或PHP日期函数时间。 我可以过滤数组或使用类似XMLPath的东西进行过滤。 不确定什么是最有效的,最好的。 $axml = Array{ “Bookings”:{ “Data”:[ { “BookingDate”:[ “2014-05-09T00:00:00” ], “RoomDescription”:[ “Room06” ], “TimeEventStart”:[ “2014-05-09T14:00:00” ], “TimeEventEnd”:[ “2014-05-09T14:30:00” ], “EventName”:[ “Jake Long” ], “SetupTypeDescription”:[ “(none)” ], “ReservationID”:[ “137” ], “OpenTime”:[ “1900-01-01T00:00:00” ], “CloseTime”:[ “1900-01-01T00:00:00” ], “EventTypeDescription”:[ [ ] ], […]

如何查询带有jQuery的Best Buy Remix API?

这是我一直在尝试使用的代码: $.getJSON(“http://api.remix.bestbuy.com/v1/products(search=” + escape(searchCriteria) + “)?apiKey=” + hhApiKey + “&format=json&callback=?”, function(data) { if(data.error) { alert(“I’m sorry, there was an error processing your request.”); } else { alert(data); } }); 但是,返回的数据有错误,因为它不理解请求的URL。 我查看了Firebug中的网络标签,这里是它试图呼叫的url: http://api.remix.bestbuy.com/v1/products(search=digital%20camera)?apiKey=myapikey&format=json&callback=json1264868431&_1254866270659 = 我认为这个问题存在于粗体部分,据我所知,这部分是无缘无故的。 我认为Remix API看到它并认为它是一个拙劣的参数。 有没有办法阻止它被添加?

如何使用JSONP将复杂数组发送到asp.net mvc控制器

我如何使用JSONP 发送复杂类型对象与其中的数组 var product= {categories:[ {id:1,text:”cat 1″},{id:2,text:”cat 2″}],id:43,price:3535}; $.getJSON(url ,product, function (data) { //i can get the data from the server but i cant pass the complex array to the server }); 并在asp.net mvc服务器上: public JsonpResult Create(Product product) { string thisisok = product.id; string needthis = product.categories[0].text; return new JsonpResult { Data = true }; […]

简单的jsonp无法使用php服务器

我尝试了一些基本的例子,但它没有用。 我不确定我是否完全理解jsonp,但是我遵循基本教程并且在直观的层面上,我看不出有什么不对。 (当然,我错过了一些东西,因此问题)。 JavaScript代码: postData = $(this).serialize(); console.log(postData); $.ajax({ data: postData, url: ‘externaldomain.php’, dataType: ‘jsonp’, success: function(data){ console.log(data); alert(‘Your comment was successfully added’); }, error: function(){ console.log(data); alert(‘There was an error adding your comment’); } }); PHP代码: $tag = mysql_real_escape_string($_GET[“callback”]); 令人讨厌的部分是,它甚至没有向我显示错误。 任何人都可以帮忙解决问题吗?

过滤到JSON中的特定节点 – 使用grep还是map?

我正在使用themoviedb.org的API来检索有关电影的信息。 它正在返回此JSON数据 。 我需要以两种不同的方式过滤它,但不一定在同一个回调中。 在一个实例中,我只需要返回类型,在另一个实例中,我只需要返回size.toLowerCase() == ‘original’的“背景”,并且两个实例都success进行ajax调用,即: $.ajax({ url: “http://api.themoviedb.org/2.1/Movie.getInfo/en/json/API_KEY/” + filmID, dataType: “jsonp”, context: document.body, success: function(data){ … } }); grep或map是否适合在这里使用? 无论如何,我如何有效地检索此信息?

如何使用$ .ajax将正常的JSON检索为JSONP?

我有一个正常的JSON提要,我在一个url(normalJSONfeed)轮询。 我每次都收到cross origin policy error 。 当我无法更改JSON提要(换句话说,我无法在函数调用中包装JSON提要)时,如何更改$.ajax函数以解决此限制。 $.ajax({ type : “GET”, dataType : “jsonp”, url : ‘/normalJSONfeed’, data : {} success: function(obj){ } });

使用jQuery和Yahoo的Geolocation API“无效标签”parsererror

我正在使用jQuery访问Yahoo的Geolocation API。 即使我能够从他们的服务器成功检索数据,我也无法让jQuery成功解析数据。 我已经尝试了$ .ajax()和$ .getJSON,每个都返回相同的失败:parsererror和“invalid label”。 通过我对interwebs的挖掘,我发现“无效标签”很可能是JSON没有被括在括号中的结果,但是在解析之前我无法弄清楚如何将数据包装起来。 我甚至不相信这是问题所在。 这是我的代码: $(document).ready(function() { var url = “http://where.yahooapis.com/geocode?q=39.0334171,-94.8320452&gflags=R&flags=JT&appid=supersecretappid&callback=?”; $.getJSON(url, function() { alert(“success”); }) .error(function(data) { alert(JSON.stringify(data)); }); }); 仅使用$ .ajax的备用版本如下: $.ajax({ url: url, data: {}, dataType: “jsonp”, contentType: “text/plain”, success: function(json) { alert(“success”); }, error: function(x,y,z) { alert(JSON.stringify(x)); } }); 非常感谢提前。

AJAX JSONP调用时执行时间重叠

我有一个jsonp ajax调用,它被执行并将数据返回给我的main函数。 这是通过调用that.mainfunction(newData);在success函数中完成的that.mainfunction(newData); 这意味着第二次调用main函数,我认为我正在运行时间/执行问题。 在第一次迭代中运行时, newData为空,并返回空主函数。 我必须使用这个框架的主要function。 所以另一个控件试图调用空的getter。 因此控制是空的。 然后第二次迭代开始。 数据在这里,脚本调用that.mainfunction(newData); 并将数据返回到main函数。 但 第二次迭代运行的时间太晚,无法将数据传输到控件。 因为它已经尝试获取数据。 如何避免这个时间/执行问题? 在使用jquery时是否可以发布/订阅一些事件总线? 这是一些代码: sap.designstudio.sdk.Component.subclass(“component”, function() { var that = this; this.processDataFromServer = function(){ function getData(callback){ $.ajax({ url: path, dataType: ‘jsonp’, contentType: “application/json”, success: function(data){ callback(data); } }); }; getData(processData); function processData(data){ this.processDataFromServer(data); }; } this.mainFunction = function(newValue){ if(typeOf(newValue) == “undefined”{ […]

如何让JSONP与jQuery一起使用?

我试图从Flickr API获取一些JSONP来使用: http://jsfiddle.net/SRc98/ $.getScript(‘http://api.flickr.com/services/feeds/photos_public.gne?format=json&tags=cats’, function(data, textStatus, jqxhr) { alert(data); }); 警报提供undefined ,控制台说: Uncaught ReferenceError: jsonFlickrFeed is not defined Flickr API响应有什么问题,或者有没有办法让它工作? http://api.flickr.com/services/feeds/photos_public.gne?format=json&tags=cats

没有带有数据的iframe中的JSONP回调

我正在使用铬。 我有一个iframe,我需要点击支持jsonp的url。 所以我用这个代码: $.ajax({ dataType: ‘jsonp’, url: my_url.endpoint + ‘/login/v1/token’ , data: form_to_object(“#signin_form”), context: window, // All Ajax calls to ABC are json // Response statuses other than 200 are caught in a timeout timeout: 10000, //10s // Handler for successful calls to ABC: calls that return with statusCode 200 success: function(data, textStatus, jqXHR) { […]