Google chrome Ajax post请求在chrome中不起作用

Google chrome Ajax post请求在chrome中不起作用,google-chrome,jquery,localhost,Google Chrome,Jquery,Localhost,我只想使用ajax post请求将数据发送到远程服务器。下面的代码在IE中运行良好,但在chrome中不起作用。为什么?什么是“访问控制不允许源http//localhost允许源”问题?我如何使它在chrome中也能工作。请帮帮我 var http = new ajaxRequest(); var url = "http://abcd.abc.com/login"; var params = "username=name&password=pass&a

我只想使用ajax post请求将数据发送到远程服务器。下面的代码在IE中运行良好,但在chrome中不起作用。为什么?什么是“访问控制不允许源http//localhost允许源”问题?我如何使它在chrome中也能工作。请帮帮我

 var http = new ajaxRequest();
        var url = "http://abcd.abc.com/login";
        var params = "username=name&password=pass&id=12345";
        http.open("POST", url, true);

        //Send the proper header information along with the request
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader("Content-length", params.length);
        http.setRequestHeader("Connection", "close");

        http.onreadystatechange = function() {
            //Call a function when the state changes.
            if(http.readyState == 4 && http.status == 200) {
                window.alert(http.responseText);
            }
        }
        http.send(params);


  function ajaxRequest(){
     var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
     if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
      for (var i=0; i<activexmodes.length; i++){
       try{
        return new ActiveXObject(activexmodes[i])
       }
       catch(e){
        //suppress error
       }
      }
     }
     else if (window.XMLHttpRequest) // if Mozilla, Safari etc
      return new XMLHttpRequest()
     else
      return false
    }
var http=new ajaxRequest();
变量url=”http://abcd.abc.com/login";
var params=“username=name&password=pass&id=12345”;
http.open(“POST”,url,true);
//随请求一起发送正确的标头信息
http.setRequestHeader(“内容类型”、“应用程序/x-www-form-urlencoded”);
setRequestHeader(“内容长度”,参数长度);
setRequestHeader(“连接”,“关闭”);
http.onreadystatechange=函数(){
//当状态更改时调用函数。
如果(http.readyState==4&&http.status==200){
window.alert(http.responseText);
}
}
http.send(params);
函数ajaxRequest(){
var activexmodes=[“Msxml2.XMLHTTP”,“Microsoft.XMLHTTP”]//要在IE中检查的activeX版本
if(window.ActiveXObject){//首先测试IE中对ActiveXObject的支持(因为IE7中的XMLHttpRequest被破坏)

对于(var i=0;i不允许您向其他服务器发出AJAX请求。您的脚本必须与向其发出AJAX请求的服务器运行在同一个域上,除非该服务器允许您使用上述访问控制允许源进行此操作。

不允许您向其他服务器发出AJAX请求。您的脚本必须在同一个域上运行域作为您向其发出AJAX请求的服务器,除非该服务器允许您使用前面提到的访问控制Allow Origin进行访问