关于Chrome扩展程序开发 popup.html页面通过jsonp的方式与服务端交互问题
2014-04-17 11:24
579 查看
传统web页面通过jsonp的方式与服务器端进行交互式代码为
会报错误:
Refused to load the script 'http://192.168.176.129:8000/login/?name=test&psw=123456&callback=flightHandler' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'".
在manifest.json 文件中 配置permissions参数也不行
最后查看文档 进行跨域请求时 使用
验证方法可行
另附 API文档
google文档:https://developer.chrome.com/extensions/overview
360翻译google:http://open.chrome.360.cn/extension_dev/overview.html
$.getJSON("http://192.168.176.129:8000/login/?callback=?",{name:u_name,psw:u_psw},function(data){ if(data.msg =="True"){ //success }else{ //failed } });
会报错误:
Refused to load the script 'http://192.168.176.129:8000/login/?name=test&psw=123456&callback=flightHandler' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'".
在manifest.json 文件中 配置permissions参数也不行
最后查看文档 进行跨域请求时 使用
var xhr = new XMLHttpRequest(); xhr.open("GET", "http://192.168.176.129:8000/register/?name="+username+"&psw="+password, true); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { var resp = JSON.parse(xhr.responseText); if(resp.msg =="True"){ //success }else{ //failed } } } xhr.send();
验证方法可行
另附 API文档
google文档:https://developer.chrome.com/extensions/overview
360翻译google:http://open.chrome.360.cn/extension_dev/overview.html
相关文章推荐
- chrome扩展程序开发之在目标页面运行自己的JS
- chrome扩展程序开发之在目标页面运行自己的JS
- 关于开发中html页面调整遇到的几个问题
- chrome扩展程序开发之在目标页面运行自己的JS
- SilverLight浏览器交互之:Html页面通过Javascript调用SilverLight程序内方法(附源码)
- 关于chrome一键清除所有html页面中断点的问题
- 关于使用androidstudio2.2通过CMake,NDK开发OpengGL程序中出现的extern “C”问题
- chrome扩展程序开发之在目标页面运行自己的JS
- 文件后缀与Mime类型对照表/由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。
- 关于html5与jsp页面同样的html代码展示的页面效果不一样的问题
- 手把手教你开发Chrome扩展三:关于本地存储数据
- asp.net 开发 跬步篇〔1〕_ajax web页面复杂处理延时、客户交互问题
- 关于.net编译过后的程序增加功能的一种实现方式_也可以说是.net exe注入,插件机制_开发记录
- 安卓开发_关于WebView加载页面空白问题
- chrome扩展开发之在content_script里执行目标页面的函数。
- HTTP 错误 404.3 - Not Found 由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。
- Chrome 扩展程序的开发与发布
- 微信小程序关于页面不跳转的问题
- 关于html中script和ActiveX交互的问题