2010-11-11 98 views
0

我有以下表單在Chrome中工作得很好,但在Firefox中似乎不起作用。一些谷歌搜索已經告訴我,它的跨域問題。我無法弄清楚如何修復它?Jquery Ajax表單,跨域火狐問題

此外,我確實嘗試將它發送到本地php文件,該文件將重定向到具有變量的跨域URL,但這似乎也沒有辦法。任何幫助將非常感激!

<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> 

回答

1

這聽起來像你已經回答了你自己的問題。這確實聽起來像是一個跨域問題。而你最好的解決方法就是你提出的修復方案。發佈到您自己的PHP腳本,發佈到遠程URL。如果您嘗試過並且無法正常工作,則可能是因爲缺少套接字支持或selinux或防火牆問題或者php安全模式設置或其他因素。您應該嘗試再次重新實施,收集所有關於該問題的數據並提出有關該部分的問題。

+0

我不得不開啓我的PHP方法並使用一點CURL – Elliot 2010-11-11 18:39:21

0

你的問題我不太清楚,不過如果你有問題跨域AJAX,我想使用JSONP應該幫助你

http://api.jquery.com/jQuery.getJSON/

尋找「JSONP」

我假設你在這裏得到一個JSON響應...