jQuery Ajax表单,跨域Firefox问题 [英] Jquery Ajax form, Cross-domain Firefox issues

查看:84
本文介绍了jQuery Ajax表单,跨域Firefox问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下表格在Chrome中可以正常使用,但在Firefox中似乎不起作用.一些Google搜索已通知我这是一个跨域问题.我不知道该如何解决?

I have the following form working just fine in Chrome, but doesn't seem to work in Firefox. Some google searches have informed me that its a cross domain issue. I couldn't figure out how to fix it though?

此外,我确实尝试将其发送到本地php文件,该文件将使用变量重定向到跨域URL,但这似乎也不起作用.任何帮助将不胜感激!

Also, I did try sending it to local php file which would redirect to the cross domain URL with the variables, but that didn't seem to do the trick either. Any help would be much appreciated!

<script type="text/javascript">

  $(function() {
    $("#requestaction").click(function() {
      $("#thecallform").fadeOut(1000, function(){
           $("#crcontent-thanks").fadeIn(500);
      });
      // validate and process form here

      var fname = $("input#first_name").val();
      var lname = $("input#last_name").val();
      var email = $("input#email").val();
      var phone = $("input#phone").val();
      var retURL = $("input#retURL").val();

 var dataString = 'first_name='+ fname + '&email=' + email + '&phone=' + phone + '&last_name=' + lname + '&retURL=' + retURL;
  //alert (dataString);return false;
  $.ajax({
    type: "POST",
    url: "http://www.blah.com?",
    data: dataString
    });
    return false;

    });
  });

    </script>

<form name="reqform" id="reqform" action="">
<input id="retURL" name="retURL" type="hidden" value="http://www.google.com" />
<div style="float:right;font-weight:bold;line-height:50px;padding-right:20px;padding-top:11px;margin-right:-3px;">
    <div id="affiliates">
        <a href="/invest" style="color: rgb(0, 0, 0); text-decoration: none;"> </a>
        <div style="margin: 4px auto; width: 112px;">
            <div class="button-left">
                &nbsp;</div>
            <div class="button-middle">
                <div class="submit-button" id="requestaction" style="line-height: 36px; width: 100px; text-align: center;cursor:pointer;">
                    Request a Call</div>
            </div>
            <div class="button-right">
                &nbsp;</div>
        </div>
    </div>
</div>

<div><input id="first_name" name="first_name" type="text" value="First Name" class="callforminput" style="margin:6px 10px 0px 10px" onfocus="if(this.value=='First Name'){this.value=''};" onblur="if(this.value==''){this.value='First Name'};"></div>
<div><input id="last_name" name="last_name"type="text" value="Last Name" class="callforminput" style="margin:6px 10px 0px 0px" onfocus="if(this.value=='Last Name'){this.value=''};" onblur="if(this.value==''){this.value='Last Name'};"></div>
<div style="clear:left;"><input id="email" name="email" type="text" value="E-mail" class="callforminput" style="margin:6px 10px 0px 10px" onfocus="if(this.value=='E-mail'){this.value=''};" onblur="if(this.value==''){this.value='E-mail'};"></div>
<div><input id="phone" name="phone" type="text" value="Phone" class="callforminput" style="margin:6px 10px 0px 0px" onfocus="if(this.value=='Phone'){this.value=''};" onblur="if(this.value==''){this.value='Phone'};"></div>
</form>

推荐答案

听起来您已经回答了自己的问题.确实确实听起来像跨域问题.最好的解决方法是建议的修复程序.发布到您自己的发布到远程URL的php脚本.如果您尝试了此操作,但它不起作用,则可能是由于缺少套接字支持,selinux或防火墙问题或php安全模式设置或其他因素所致.您应该尝试重新实现该方法,并收集所有有关它的数据,并提出与该部分有关的问题.

It sounds like you have answered your own question. It does indeed sound like a cross domain issue. And your best workaround, is the fix that you suggested. Posting to your own php script that posts to the remote url. If you tried that and it didn't work, it may have been due to the lack of sockets support or selinux or firewall issue or php safe mode setting or some other factor. Which you should try to re-implement again, and gather all the data you can about it and ask a question relating to that portion.

这篇关于jQuery Ajax表单,跨域Firefox问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆