Ajax / JQuery / JSON表单

I've got a form which I need to post the information to an external site, but for some reason I'm getting an error:

Error: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "jquery.core.1-3-2.min.js Line: 19"] Source File: jquery.core.1-3-2.min.js Line: 19

Here's the code that I'm using to do the form (or attempt to do so):

<script type="text/javascript" language="javascript">
$(function() {

  $(".FormButtons").click(function() {

    var name        = $("input#contactDataFirstName").val();
    var lname       = $("input#contactLastName").val();
    var gender      = $("input#contactDataGender").val();
    var dobd        = $("input#contactDataDateOfBirthday").val();
    var dobm        = $("input#contactDataDateOfBirthmonth").val();
    var doby        = $("input#contactDataDateOfBirthyear").val();
    var mobile      = $("input#contactDataMobilePhoneNumber").val();
    var street      = $("input#contactDataStreetAddress").val();
    var suburb      = $("input#contactDataSuburbTownCity").val();
    var postcode    = $("input#contactDataPostcode").val();
    var country     = $("input#contactDataCountry").val();
    var state       = $("input#contactDataCountrySubdivisionIDNew").val();
    var password    = $("input#contactDataPassword").val();
    var email       = $("input#contactDataEmail").val();
    var remail      = $("input#contactDataReceiveEmail").val();
    var rmail       = $("input#contactDataReceiveMail").val();
    var rsms        = $("input#contactDataReceiveSMS").val();

    var dataString = 'contactDataFirstName='+ name + '&contactLastName=' + lname + '&contactDataGender=' + gender + '&contactDataDateOfBirthday=' + dobd + '&contactDataDateOfBirthmonth=' + dobm + '&contactDataDateOfBirthyear=' + doby + '&contactDataMobilePhoneNumber=' + mobile + '&contactDataStreetAddress=' + street + '&contactDataSuburbTownCity=' + suburb + '&contactDataPostcode=' + postcode + '&contactDataCountry=' + country + '&contactDataCountrySubdivisionIDNew=' + state + '&contactDataPassword=' + password + '&contactDataEmail=' + email + '&contactDataReceiveEmail=' + remail + '&contactDataReceiveMail=' + rmail + '&contactDataReceiveSMS=' + rsms;

    $.ajax({
      type: "POST",
      url: "path_to_url",
      //dataType: "jsonp", 
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id=\"message\"></div>");
        $('#message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        /*.fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });*/
      }
     });
    return false;
    });
});
</script>

Could someone please help me post my data to the external website :)

Browsers have a security concept called same-origin policy whereby AJAX requests can only access the domain from which the page source has originated from (with some minor caveats and workarounds, but long and short..)

Your best bet is to POST to a local page which acts as a proxy, it will do the "real" HTTP POST to the external site.

You can check this site for a solution.

Due to cross domain restrictions it is impossible to POST with AJAX to a different domain. The way jsonp works is it inserts a <script> tag inside the DOM so it performs a GET request.

No need to use variable for every input in the form.

you can use $("form").serialize( ) to post all the input fields.

var str = $("form").serialize();

see here jquery form Serialize