I want to explain first ...
I have two domain .. www.one.com and www.two.com
First domain www.one.com Form input here
<div class="hidden cswrap2">
<h3>Edit Data Mustahik</h3>
<div class="cscontent">
<ul class="cslist">
<li id="">
<form action="javascript:void(0);" name="editmustahik">
<div style="margin-bottom: 10px; width: 230px;">
<label>Kuantitas</label>
<input type="text" name="kuantitas" value="<?php echo @$mpzis['kuantitas'];?>" style="width:230px;">
<input type="text" name="nik" value="<?php echo @$mpzis['nik'];?>" style="width:230px;">
<input type="text" name="amil_email" value="<?php echo @$mpzis['email_amil'];?>" style="width:230px;">
</div>
</form>
</li>
</ul>
</div>
<div class="csbutton">
<input type="button" name="buttonstatus" onclick="hideCustomStatus('cswrap2');" value="Batal" id="customstatusbutton">
<input type="submit" onclick="UpdateDataMustahik();" value="Update">
</div>
</div>
this ajax post
function UpdateDataMustahik() {
var formData = $('form[name="editmustahik"]').serialize();
displayCustomStatus('Update Data Mustahik');
addCustomStatusContent('Updating Data','update777');
$.ajax({
url: 'www.two.com/api_controller/update',
type: 'POST',
dataType: 'json',
data: formData,
success: statusUpdate
});
}
function statusUpdate(json) {
if(json.status_code == '000') {
addCustomStatusContent('Sukses','update777');
}
}
i have second domain to direct there .. www.two.com/api_controller/update --> url: 'www.two.com/api_controller/update',
in controller i was put this code
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
but still not working .. error display is 404 not found ..
may you know how to solve this ..
Thanks
Try
$.ajax({
url: url
//dataType: 'json',
type: 'POST',
xhrFields: {
withCredentials: true
},
crossDomain: true,
data: {data:data},
success: function (data) {
//your code
} });