I am using jQuery and jQuery form plugin
There is a method in jQuery form plugin ajaxSubmit. You pass a form and then it submits it via ajax and you get a response. I am wondering how this is possible since the form is on a different server than the web page. (Different domains). It appears to work and I get back a response that I can process. How does this work?
domain form is hosted on (http://example.com)
form url: 127.0.0.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP Point Of Sale</title>
<script src="<?php echo base_url('/assets/js/jquery.js'.'?'.APPLICATION_VERSION); ?>"></script>
<script src="<?php echo base_url('js/jquery.form.js'.'?'.APPLICATION_VERSION); ?>"></script>
</head>
<body>
<form id="formCheckout" method="post" action="<?php echo $form_url; ?>">
<?php foreach($post_data as $key=>$value) { ?>
<?php echo form_hidden($key, $value);?>
<?php } ?>
</form>
<script>
$("#formCheckout").ajaxSubmit({
success: function(response) {
console.log(response);
}
});
</script>
</body>
</html>
See Question&Answers more detail:os