Javascript 跨域使用Ajax Codeigniter的Ajax POST
我想先解释一下 我有两个域名。。www.one.com和www.two.com 第一域名www.one.com 这里的表单输入Javascript 跨域使用Ajax Codeigniter的Ajax POST,javascript,php,jquery,ajax,codeigniter,Javascript,Php,Jquery,Ajax,Codeigniter,我想先解释一下 我有两个域名。。www.one.com和www.two.com 第一域名www.one.com 这里的表单输入 <div class="hidden cswrap2"> <h3>Edit Data Mustahik</h3> <div class="cscontent"> <ul class="cslist"> <li id=""> <form action="
<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>
我在那里有第二个域名。。
www.two.com/api_controller/update->
网址:“www.two.com/api_controller/update”
在控制器中,我输入了以下代码
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
但是仍然不起作用。。
找不到错误显示404
请你知道如何解决这个问题
谢谢试试看
$.ajax({
url: url
//dataType: 'json',
type: 'POST',
xhrFields: {
withCredentials: true
},
crossDomain: true,
data: {data:data},
success: function (data) {
//your code
} });
在构造函数中?是的-->>公共函数{parent::_construct;header'Access-Control-Allow-Origin:';headerAccess-Control-Allow方法:GET、POST、OPTIONS、PUT、DELETE;在第二个域-->www.two.comput crossDomain:true,在ajax请求中的数据参数之后。谢谢。您能在将头代码放在第一个加载的公共页后检查一下吗ng like.CI=>index.php
$.ajax({
url: url
//dataType: 'json',
type: 'POST',
xhrFields: {
withCredentials: true
},
crossDomain: true,
data: {data:data},
success: function (data) {
//your code
} });