开发者

Jquery Ajax form, Cross-domain Firefox issues

开发者 https://www.devze.com 2023-01-24 09:06 出处:网络
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 t

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?

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="te开发者_运维问答xt" 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>


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.


Your question is not very clear to me, however if you're having problems cross domain ajax, I guess using jsonp should help you out

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

look for "jsonp"

I'm assuming you get a json response here...

0

精彩评论

暂无评论...
验证码 换一张
取 消