科尔多瓦ios SecurityError上的Ajax调用:DOM异常18 [英] Ajax call on Cordova ios SecurityError: DOM Exception 18

查看:101
本文介绍了科尔多瓦ios SecurityError上的Ajax调用:DOM异常18的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Cordova(5.1.1)/Phonegap构建一个iOS应用程序,但是我有一个无法解决的问题.

Hi I'm building an iOS application via Cordova(5.1.1)/Phonegap and I have a problem I can´t solve.

一个基本的Ajax调用会抛出一个SecurityError: DOM Exception 18我尝试了所有有关白名单的技巧,但现在我迷路了.有谁可以帮助您?谢谢.

A basic Ajax call throws a SecurityError: DOM Exception 18 I tried all the tricks regarding whitelisting and now I'm lost.. Anyone who can help? Thanks.

这是设备准备好后我要做的事情:

Here is what I do after device is ready:

    var getUrl = 'http://shopplo.com/api/posts/radius/'+app.lat_min+'x'+app.lat_max+'x'+app.lng_min+'x'+app.lng_max+'';

    //console.log(getUrl);

    var getPosts = $.ajax({
          method: 'GET',
          url: getUrl,
          dataType: 'JSON'
        })
        .done(function(e) {
            console.log( e );


        })
        .fail(function(e) {
            //console.log( "error");

            $.each(e, function(key, element) {
                console.log('key: ' + key + '\n' + 'value: ' + element);
            });

        })
        .always(function() {
            console.log( "complete" );
        });

getUrl是: http://shopplo.com/api/posts/radius/37.11032230061141x73.11032230061141x-20.572796183027627x42.36447502674581

我得到:

2015-07-20 01:12:55.981 ShopploLight[779:568632] key: responseJSON :: value: undefined
2015-07-20 01:12:55.983 ShopploLight[779:568632] key: status :: value: 0
2015-07-20 01:12:55.983 ShopploLight[779:568632] key: statusText :: value: Error: SecurityError: DOM Exception 18
2015-07-20 01:12:55.984 ShopploLight[779:568632] complete

推荐答案

检查您的元标记. 默认情况下,它使用:

Check your meta tag. By default, it uses:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">

使用下面的代码启用所有请求

use the code below to enable all requests

<!-- Enable all requests, inline styles, and eval() -->
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src: 'self' 'unsafe-inline' 'unsafe-eval'">

这篇关于科尔多瓦ios SecurityError上的Ajax调用:DOM异常18的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆