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

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 上传到服务器后不允许使用英特尔XDK Ajax访问[在xampp中运行良好]脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在构建一个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>
@H_404_29@解决方法
问题出在服务器上的PHP版本中,当我用新的PHP版本更改服务器时,一切正常运行!

脚本宝典总结

以上是脚本宝典为你收集整理的php – 上传到服务器后不允许使用英特尔XDK Ajax访问[在xampp中运行良好]全部内容,希望文章能够帮你解决php – 上传到服务器后不允许使用英特尔XDK Ajax访问[在xampp中运行良好]所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。