繁体   English   中英

使用ajax发送发布请求时出错

[英]error in sending a post request using ajax

我正在尝试使用ajax发送发帖请求,但我不断收到以下错误:

XMLHttpRequest无法加载http://192.168.1.123:8080 对预检请求的响应未通过访问控制检查:请求的资源上不存在“ Access-Control-Allow-Origin”标头。 因此,不允许访问源' http:// localhost:8080 '。

这是我的代码

 $.ajax({ type: "POST", url: "http://192.168.1.123:8080", data: JSON.stringify([{"VisitorName ": " "+document.getElementById("VisitorName ").value} ]), contentType: "application / json ", crossDomain: true, dataType: "json", success: function (data) { alert(data); }, failure: function (errMsg) { alert(errMsg); } }); 

   $.ajax({
      type: "POST",
      url: "http://192.168.1.123:8080,
                data: JSON.stringify([
                {
                    "
      VisitorName ": "
      "+document.getElementById("
      VisitorName ").value,
      }

据我所知, value旁边的逗号引起语法错误。 另外,代码中你没有关闭""http://192.168.1.123:8080

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM