douchuang1861 2015-06-18 12:36
浏览 328

CORS不允许jquery AJAX获得结果

I am calling an AJAX function in my script from a server of IP - 128.119.30.12:7080 (for example)

Cross Domain: port number are different, so I get error of incompatibility.

            $.ajax({
                url: "http://128.119.30.12:9000/callback.php",
                data: dataObj,
                type: "POST",
                contentType: 'text/plain',
                sucess: function(data,status){
                    reply = data;
                }, 
                error : function(xhr, status, error){
                    reply = {"error": "Error in fetching data"}
                }
            }).done(function(reply) {
                replyCall(reply);
            });

            function replyCall(data) {
                console.log(data);
            }

I have enabled the mod_header function in my Apache server. And setting up header in the called php script - here is the script of php

<?php
    header('Access-Control-Allow-Origin: *'); 
    header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
    print 'Hellooooooooo Response';
?>

It is still causing errors on chrome - XMLHttpRequest cannot load http://128.119.30.12:9000/callback.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://128.119.30.12:7080' is therefore not allowed access.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码