jsonp

using jquery + jsonp, Internet explorer isn't saving the ASP.NET sessionID

落花浮王杯 提交于 2019-12-06 05:38:56
So I am doing some fairly simple JSONP stuff using Jquery. General structure Site lives on domain A Javascript lives on domain B JSON services also live on domain B The site calls a method which jsonp calls out to a json service (.net) , in .net i set the session and return. This all works fine, except in IE it is not storing or passing the session id in subsequent requests.. So .net creates a new one every time. If i go to the JSON url directly, ie happily stores it, and will use it on subsequent calls. Firefox and chrome don't have any problem with this, but for some reason IE seems to be

PHP, jQuery Ajax and json return over a cross domain

為{幸葍}努か 提交于 2019-12-06 05:17:22
I have my php coded page on one server that returns a json result. php file called: getInfoData.php and the return is as below. echo json_encode($v); No I can use $.getJSON(??) to read the json and run it all on the same sever fine, but I need the php page to be on a different sever than the js page calling it. But then I get then when I do I get the cross domain issue. So I changed the code to use the following (jsonp): $.ajax({ url: 'FILE_LOCATION_ON_ANOTHER_SERVER', type: 'GET', crossDomain: true, dataType: 'jsonp', success: function() { console.log("Success"); }, error: function() {console

ASP.NET Generic HTTP Handler (.ashx) supporting JSONP

旧时模样 提交于 2019-12-06 05:04:50
Can someone show an example of an HTTP Handler that returns JSON and supports cross domain calls. I am using jQuery's getJSON() that sends a request to an .ashx file on my web server. I understand that I need to add ?callback=? to my url in the getJSON() url, but I'm not sure what needs to be done on the server in my ashx file? Figured it out. I added this function to my handler and called it: void WriteCallback(HttpContext context, string json) { context.Response.Write(string.Format("{0}({1});", context.Request["callback"], json)); } Then in the browser: $(function () { $.getJSON('MyHandler

JS AJAX和JSONP的基础功能封装以及使用示例;

北慕城南 提交于 2019-12-06 04:55:46
1.代码: 1 function ajax(options){ 2 options = options || {}; 3 options.type = options.type || "get"; 4 data = options.data || {}; 5 // 处理数据 6 var str = ""; 7 for(var i in data){ 8 str += `${i}=${data[i]}&`; 9 } 10 // 判断type类型拼接url 11 if(options.type == "get" || options.type == "jsonp"){ 12 var d = new Date(); 13 url = `${options.url}?${str}d=${d.getTime()}`; 14 }else{ 15 url = options.url; 16 } 17 // console.log(`拼接后的url是${url}`); 18 // 判断type类型走jsonp还是创建ajax 19 if(options.type == "jsonp" ){ 20 var script = document.createElement("script"); 21 script.src = url; 22 document.body.appendChild

Sencha Touch 2 - JSONP proxy help, template always has null for values

限于喜欢 提交于 2019-12-06 03:57:45
问题 I'm having trouble getting actual data to show up in a Sencha Touch 2 list. The list should be populated by a JSONP response, and I expect 2 rows to show up. Instead, I get one row with 'null at null'. Here's the URL that gets sent: http://some-server/data-fetcher.php?_dc=1331910031292&events=true&page=1&start=0 &limit=25&callback=Ext.data.JsonP.callback1 Here's the JSONP response: Ext.data.JsonP.callback1({"data":[{"id":"4","name":"Sample Name 1", "description":null,"location":"Sample

Any way to limit access to CouchDB view when JSONP is enabled?

我是研究僧i 提交于 2019-12-06 03:45:45
问题 I enabled JSONP on my iriscouch CouchDB so I could make ajax requests to my views. This means that anybody can make ajax request to my CouchDB views. Is there any way to prevent this? If not, then is there a way to limit access to the views (with JSONP turned off) so that only my application can view it (using a proxy)? 回答1: Cross-domain functionality is still difficult. I do not think JSONP allows authenticated requests, therefore your choice with JSONP is between totally public data and

Are there reasons not to use JSONP for AJA~X requests?

流过昼夜 提交于 2019-12-06 01:34:08
问题 If you're building an AJA~Xy app, are there any downsides to using JSONP requests/responses even if you're not planning on any cross-domain requests? The only thing I can think of is that there are a couple extra bytes for the callback wrapper... Edit: I found this which also suggests security and error handling as potential problems... There's no error handling. The script injection either works, or it doesn't. If there's an error from the injection , it'll hit the page, and short of a

前端跨域解决方案的总结

◇◆丶佛笑我妖孽 提交于 2019-12-06 01:11:01
前言 前后端处理数据交互时往往会遇到跨域的问题,那么什么是跨域? 有哪些跨域方式? 出现跨域又该如何解决呢? 一、什么是跨域? 理解跨域首先要理解同源策略,它是浏览器对js施加的一种安全限制,如果缺少了同源策略,浏览器很容易受到XSS、CSFR、SQL注入等攻击。所谓同源是指协议、域名、端口必须相同。浏览器在请求数据时都要遵循同源策略,那么凡是发送请求的URL中协议、域名、端口三者之中的一点不同时,就叫做跨域。 而在同源策略当中,它所限制的内容就有以下几个: Cookie、LocalStorage、IndexedDB 等存储性内容 DOM 节点 AJAX 请求不能发送 但是以下三个标签是允许跨域加载资源的: img中的src属性: <img src=XXX> link标签的href属性: <link href=XXX> script的src属性: <script src=XXX> 常见的跨域场景上面的图表已经说了,在 协议 , 域名 , 端口号 三者中,倘若其中之一不相同都会导致跨域的现象. 在此特别说明的两点: 第一:如果是协议和端口造成的跨域问题“前台”是无能为力的。 第二:在跨域问题上,仅仅是通过“URL的首部”来识别而不会根据域名对应的IP地址是否相同来判断。“URL的首部”可以理解为“协议, 域名和端口必须匹配” 。 这里你或许有个疑问: 请求跨域了

简单透彻理解JSONP原理及使用

Deadly 提交于 2019-12-05 22:48:55
什么是JSONP 首先提一下JSON这个概念,JSON是一种轻量级的数据传输格式,被广泛应用于当前Web应用中。JSON格式数据的编码和解析基本在所有主流语言中都被实现,所以现在大部分前后端分离的架构都以JSON格式进行数据的传输。 那么JSONP是什么呢? 首先抛出浏览器同源策略这个概念,为了保证用户访问的安全,现代浏览器使用了同源策略,即不允许访问非同源的页面,详细的概念大家可以自行百度。这里大家只要知道,在ajax中,不允许请求非同源的URL就可以了,比如www.a.com下的一个页面,其中的ajax请求是不允许访问www.b.com/c.php这样一个页面的。 JSONP就是用来解决跨域请求问题的,那么具体是怎么实现的呢? JSONP原理 ajax请求受同源策略影响,不允许进行跨域请求,而script标签src属性中的链接却可以访问跨域的js脚本,利用这个特性,服务端不再返回JSON格式的数据,而是返回一段调用某个函数的js代码,在src中进行了调用,这样实现了跨域。 JSONP具体实现 1.首先看下ajax中如果进行跨域请求会如何。 前端代码在域www.practice.com下面,使用ajax发送了一个跨域的get请求 <!DOCTYPE html> < html > < head > < title > GoJSONP </ title > </ head > <

ajax 'GET' call returns jsonp okay but callback produces 'undefined' data

北慕城南 提交于 2019-12-05 22:43:53
I'm accessing a cross-domain webservice utilizing an.ajax jquery call from an html page. While I can see the jsonp data using firebug, I am not able to load it into a variable or even display it (for debugging purposes). Attempts to retrieve data using the jsonpCallback, success and complete functions always result in 'undefined' / null data. Ultimately, I need to save the data to variables. Any assistance will be greatly appreciated! $.ajax({ data: { User: UserValue, GUID: GUIDValue }, cache: false, dataType: "jsonp", // tried json type: "GET", crossDomain: true, jsonp: false, // tried true