【问题标题】:cross domain not working for ios phonegap跨域不适用于 ios phonegap
【发布时间】:2016-07-06 04:41:31
【问题描述】:

其实我有一个关于 IOS 平台 phonegap 的 ajax 请求。我有两个域,例如 1.example.com/folder/contact.php?id=id,另一个是 2.example2.com/folder/contact.php?id=id

因此,当 url 到达第二个域 (example2.com) 时,什么都没有发生,但对于第一个域 (example.com),它可以正常工作。我配置了config.xml,这里的access-origin是“*”,我也在config.xml中设置了

我不明白出了什么问题。我的ajax代码是

$.ajax({
      type: 'GET',
      url: ""+localStorage.url+"/folder/contact.php?id=" + Id,
	  dataType: 'json',
	  crossDomain: true, 
	 
      data: {
        name: name,
        ph: ph,
        email:email,
        },
     success: function(response) {
		  alert(response);
},

error: function(error) {
		
        navigator.notification.alert('Could not connect to the database');
      }
    });

但同样的事情也适用于 android 平台。请告诉我我的代码有什么问题

【问题讨论】:

    标签: ios cordova cross-domain phonegap-build phonegap-cli


    【解决方案1】:

    我已经解决了这个问题。实际上问题出在页眉元内容中。我不得不在内容差距中提到域 example.com 和 example2.com。像这样

    gap: https://ssl.gstatic.com https://*.googleapis.com http://example.com http://example2.com ;script-src 'self' 'unsafe-inline' 'unsafe-eval' https://maps.googleapis.com https://maps.gstatic.com https://mts1.googleapis.com https://mts0.googleapis.com http://example.com http://example2.com ;object-src * ; style-src 'self' 'unsafe-inline' https://ssl.gstatic.com https://fonts.googleapis.com http://example.com http://example2.com ; media-src *;img-src *;font-src *">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-04
      • 2014-12-30
      • 2014-09-08
      • 2013-02-28
      • 2020-01-11
      • 1970-01-01
      相关资源
      最近更新 更多