duaner5714 2014-06-20 17:08
浏览 36
已采纳

跨域ajax请求失败,重置为peer

I have following configuration. Website on domain1 makes ajax-request (jQuery.ajax) to API on domain2, I can see in error_log api script works fine, but sniffer on client side detects Reset by peer error with no response body. This is strange case because there are lot of other similar websites communicating with this api via cross domain request and everything's ok. Can someone give me the clue how to track this? I'm supplying all necessary http-headers on server

<?php      
  header('Access-Control-Allow-Origin: *');
  header('Access-Control-Allow-Methods: GET');
  header('Access-Control-Allow-Headers: Origin,cache-control,content-type,man,messagetype,soapaction');
  • 写回答

2条回答 默认 最新

  • doupang3062 2014-06-20 17:52
    关注

    I think what you need is JSONP, JSONP is allowed to make CORS calls since they have a different origin policy, if you are using jQuery it has built in functions for that.

    See http://api.jquery.com/jquery.getjson/ and http://api.jquery.com/jQuery.ajax/ (the jsonp stuff options)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 socket通信实现多人聊天室疑惑
  • ¥15 DEV-C++编译缺失
  • ¥33 找熟练码农写段Pyhthon程序
  • ¥100 怎么让数据库字段自动更新
  • ¥15 antv g6 力导向图布局
  • ¥15 quartz框架,No record found for selection of Trigger with key
  • ¥15 锅炉建模+优化算法,遗传算法优化锅炉燃烧模型,ls-svm会搞,后面的智能算法不会
  • ¥20 MATLAB多目标优化问题求解
  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数