加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 上传到服务器后不允许使用英特尔XDK Ajax访问[在xampp中

发布时间:2020-12-13 22:25:01 所属栏目:PHP教程 来源:网络整理
导读:我正在构建一个XDK应用程序, 在xampp工作得很好并修复了标题问题,上传到实时服务器后ajax调用无效,我收到此错误 XMLHttpRequest cannot load http://watanydemo.eb2a.com/metawe3/action/get?_=1451186106865. No 'Access-Control-Allow-Origin' header is p
我正在构建一个XDK应用程序,
在xampp工作得很好并修复了标题问题,上传到实时服务器后ajax调用无效,我收到此错误

XMLHttpRequest cannot load http://watanydemo.eb2a.com/metawe3/action/get?_=1451186106865. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
index.html:92 {"readyState":0,"status":0,"statusText":"error"}

虽然我通过所有方式设置标题,但仍将原点设置为null

public function get()
{ $this->load->model('Name_model');  
$result = $this->Name_model->read_names();
header('Access-Control-Allow-Origin: *');
header('Content-type: application/json');

echo json_encode($result);
}

NB我的后端是Codeigniter

我的Ajax调用是

<script type="text/javascript">

        $(document).ready(function() {

$('#loading-image').show();
            try {
        $.ajax({
            type: "GET",url: "http://watanydemo.eb2a.com/metawe3/action/get",crossDomain: true,contentType: "application/x-www-form-urlencoded",async: true,dataType: 'json',processData: false,cache: false,success: function (response) {
                alert("valid response");

for (var i = 0,res = response.length; i < res; ++i) {
 var picture = response[i].picurl;
var name= response[i].name;


 $("#row").append('<div class="col-md-4"><h1>'+name+'</h1><img id="pic" class="thumbnail img-responsive" alt="Bootstrap template"src="'+picture+'" />'+'<div class="well"></div></div>');
 }
            },complete: function(){
    $('#loading-image').hide();
  },error: function (ErrorResponse) {
              console.log(JSON.stringify(ErrorResponse));
            }
        });
    }
    catch (error) {
                  console.log(JSON.stringify(error));

    }


    });  

    </script>

解决方法

问题出在服务器上的PHP版本中,当我用新的PHP版本更改服务器时,一切正常运行!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读