国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 織夢DEDE > 正文

織夢ajax跨域提交自定義表單

2024-07-12 09:08:13
字體:
來源:轉載
供稿:網友

A站(www.a.com),有個form表單,ajax提交到 B站(www.b.com),還附帶個驗證碼。

A站上的表單代碼如下:

<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script><script>function send(){    $.ajax({        cache:true,        type:"POST",        url:"http://www.b.com/plus/diy.php",        data:$('#diyform').serialize(),        xhrFields:{withCredentials: true}, //ajax跨域提交需要        crossDomain:true, //ajax跨域提交需要        success: function(data){            if(data=="success"){                alert('發(fā)送成功!');            }else{                alert('發(fā)送失敗!');            }        }    });}</script><form action="" enctype="multipart/form-data" method="post" id="diyform">    <input type="hidden" name="action" value="post" />    <input type="hidden" name="diyid" value="2" />    <input type="hidden" name="do" value="2" />    <input type="hidden" name="dede_fields" value="name,text" />    <input type="hidden" name="dede_fieldshash" value="c2be5bb5ec45d9d01ca9f60dc469b3fb" />    <p>        姓名:        <input type='text' name='name' id='name' />    </p>    <p>        驗證碼:        <input type="text" name="validate"><img src="http://www.b.com/include/vdimgck.php" align="absmiddle" onclick="this.src='http://www.b.com/include/vdimgck.php?tag='+Math.random();" style="cursor:pointer;">    </p>    <div onclick="send()">提交</div></form>

1、提交到 http://www.b.com/plus/diy.php

2、驗證碼 http://www.b.com/include/vdimgck.php

3、ajax 跨域必需js代碼

xhrFields:{withCredentials: true},

crossDomain:true,

B站上的 /plus/diy.php 文件上面加入

header("Access-Control-Allow-Credentials:true");

header("Access-Control-Allow-Origin:http://www.a.com");

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 汉川市| 延边| 泸西县| 木里| 黎城县| 霸州市| 涿州市| 盐源县| 老河口市| 山东省| 河源市| 永清县| 塘沽区| 盘山县| 吉安县| 枣阳市| 卢湾区| 宜兴市| 龙陵县| 赣榆县| 彰化市| 合江县| 全椒县| 班玛县| 南通市| 临沭县| 驻马店市| 奉贤区| 鄂托克前旗| 年辖:市辖区| 明水县| 额济纳旗| 晋宁县| 梨树县| 乃东县| 桃源县| 乌海市| 澄迈县| 稻城县| 大洼县| 天镇县|