jsonp

Can I use a static (i.e., predetermined) callback function name when requesting JSONP with jQuery?

為{幸葍}努か 提交于 2019-12-04 14:31:54
The jQuery documentation lists the following example of using $.getJSON to request JSONP: $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?", function(data) { $.each(data.items, function(i,item) { $("<img/>").attr("src", item.media.m).appendTo("#images"); if (i == 3) return false; }); }); Rather than use this method, which generates a dynamic callback function name because of this parameter: jsoncallback=? I want to be able to set that in advance to a hardcoded function name, like this: jsoncallback=test This works, in the sense

Copying cookies cross-domain, why is IE blocking cookies other browsers are sending with the SCRIPT tag

别等时光非礼了梦想. 提交于 2019-12-04 14:19:21
Trying to copy a cookie from second.com to first.com, with full control of both domains. Previously an iFrame was used, however this is not able to work across all browsers as it touched on 'third-party cookies' which are hard to implement and impossible in Safari and Chrome. The new approach uses a SCRIPT tag pointing to second.com and included in the HEAD of first.com. The server-side script is actually a piece of Java which reads the cookies sent with the request (the cookies from second.com) and the JavaScript returned executes on first.com and essentially duplicates the cookie here. This

Cross domain request with header authentication

倖福魔咒の 提交于 2019-12-04 14:03:12
I need to send a Get request with cross domain origin with header authentication. Its working fine in Chrome and Firefox, but I'm having issues in Safari and IE. Also in random cases it returns 401. <script> var url = 'username:password@anotherdomain.com'; $.ajax({ url: url, dataType: 'jsonp', jsonpCallback: "callback", success: function(json) { alert(json); } }); </script> What would be the best option to solve this? If I have understood the question correctly, you could use the beforeSend callback to add basic authentication on the request. This is irrelevant of jsonp or cross-origin though.

with jQuery, access json from cross domain url where json may be poorly formed

白昼怎懂夜的黑 提交于 2019-12-04 13:52:17
问题 I'm using jQuery's ajax function to hit a cross domain url. The url will return json. I'm in the discovery phase with this but I think, because the json values contain several '&quot' strings, the json eval is throwing an error and stopping the execution of my client side script. The error that I get is "unterminated string literal". I know that if I hard-code the returned json by putting it in a local div and remove the '"' strings (and a couple of hidden special characters), I can get the

Create a JSONP API in AngularJS & consume with jQuery

徘徊边缘 提交于 2019-12-04 13:12:40
Right now I've created a JS API with JQuery, but I'm wondering if it could be done with AngularJs. For example, Imagine a small API like the following: var $myapi= $myapi|| {}; ;(function($, window, document, undefined){ _call_myapi_jsonp: function(params,controller,action,eventName){ if (!params) params = {}; var url = this.urls.base+"/"+controller+"/"+action+"?callback=?"; if (params.callback) url = this.urls.base+"/"+controller+"/"+action+"?callback="+params.callback; url = url + "&_"+new Date(); delete params.callback; $.ajax({ url: url, data: params, crossDomain:true, dataType:'jsonp',

Is there any javascript library to capture mouse/keyboards events and send them to external server?

安稳与你 提交于 2019-12-04 11:23:03
What I need is something which: can catch all keyboard events can catch all mouse events (clicks, movement) can catch page scrolling, possibly taking care about browsers differences send data to external server using JSONP (or anything else, but need to work not only in newest browsers) is quite small, at most xx kB I hope I would like to find something which have at least 3 of above implemented properly. I can also look at js frameworks like Dojo or JQuery if they can help me, but then will I be able to to keep it small enough? How about writing it yourself ? :) Let's consider this simple

Ajax with JQuery: 200 ok, but not “success”

主宰稳场 提交于 2019-12-04 09:46:37
问题 I'm facing the same issue, while trying for cross-domain request. Situation is strange, my data is getting loaded while hit the requested url directly on browser, the strange part is, this gets loaded if requested using jquery ajax as well, but not on firebug console , but on firebug net tab. Console prints: Sample of error data: parsererror {while json data is well-formed and formatted, checked on json validators} readyState: 4 status: 200 responseText: undefined Net tab loads all the data

How to write JSONP Ajax request on pure js? [duplicate]

我只是一个虾纸丫 提交于 2019-12-04 08:46:42
This question already has an answer here: Making and handling JSONP request using JavaScript 1 answer $.ajax( { url : '', data: {}, dataType:'jsonp', jsonpCallback: 'callbackName', type: 'post' ,success:function (data) { console.log('ok'); }, error:function () { console.log('error'); } }); How do I write the same functionality in pure JS? In this particular case, you aren't making an ajax call at all, instead you're making a JSONP request. Luckily, these are incredibly easy to replicate and work in all browsers. var s = document.createElement("script"), callback = "jsonpCallback_" + new Date()

How can I use mixpanel API?

匆匆过客 提交于 2019-12-04 08:36:33
问题 I'm not able to connect to mixpanel. I have tried with a correct api_key and api_secret, like this: <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js" /> </script> <script type="text/javascript" src="faulty-labs-md5.js" /> </script> </head> <body> <script type="text/javascript"> $(document).ready(function() { $("#btnTest").click(function() { var api_key = 'BigSecret'; var api_secret = 'BigSecret2'; var expire = new Date('2012', '12', '24').getTime()

Amazon Product Advertising API : How to get a JSON response for ItemLookup/Search

柔情痞子 提交于 2019-12-04 07:47:54
问题 I'm trying to get the details of Amazon product from its ASIN. The product API allows to do a Itemlookup with ASIN , but the return value is in XML . I want to do this call for Itemlookup from client side, so would like to do a JSONP call, which I couldn't find. I found some articles on the web to convert the XML to JSON format using XSLT stylesheet: (a) https://bitbucket.org/basti/python-amazon-product-api/src/tip/examples/json-results.py I tried using this python-amazon-product-api and this