第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

jQuery下用mockjax提交表單出錯(cuò)?

jQuery下用mockjax提交表單出錯(cuò)?

<!DOCTYPE?html> <html?lang="en"> <head> ????<meta?charset="UTF-8"> ????<title>Title</title> ????<link?rel="stylesheet"?href="css/1.css"/> ????<link?rel="stylesheet"?href="css/normalize.css"/> ????<script?src="js/jquery.mockjax.js"></script> ????<script?src="js/jquery-2.2.3.min.js"></script> ????<script?src="js/1.js"></script> </head> <body> name:<input??id="name"?autofocus?placeholder="your?name"?type="text"?> tel:<input?id="tel"?autofocus?placeholder="your?telephone?number"?type="text"> e-mail:<input?id="email"?autofocus?placeholder="your?e-mail"?type="text"> <button?id="btn">submit</button> </body> </html>window.onload?=?function(){ ????$('#btn').click(function?()?{ ????????var?name?=?$('#name').val(); ????????var?tel?=?$('#tel').val(); ????????var?email?=?$('#email').val(); ????????var?data?=?{"name":?name,?"tel":?tel,?"email":email}; ????????console.log(data); ????????$.ajax({ ????????????type:?'POST', ????????????url:?'api/comment/submit', ????????????data:?JSON.stringify(data), ????????????contentType:?"application/json", ????????????dataType:?'json', ????????????success:?function?(data)?{ ????????????????console.log(data); ????????????????if?(data.code?!=?1)?{ ????????????????????//console.log(data.msg); ????????????????????alert(data.msg); ????????????????}?else?{ ????????????????????alert('短信發(fā)送成功,我們將盡快聯(lián)系您'); ????????????????} ????????????} ????????}); ????????$.mockjax({???????//??固定??必要 ????????????url:?'api/comment/submit',???//?必要?提交到后臺(tái)的URL,要與ajax中的url一致 ????????????status:?200,???//響應(yīng)狀態(tài)碼?可選 ????????????responseTime:?1000,???//?響應(yīng)時(shí)間?可選 ????????????responseText:?{????//?固定??必要??{}?花括號(hào)內(nèi)是后臺(tái)返回的json數(shù)據(jù)格式 ????????????????"code":?1, ????????????????"msg":?'success' ????????????} ????????}) ????}) ????};
查看完整描述

1 回答

?
Fiona2017

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊

是不是jq文件要放在mockjax.js文件的前面引用?

查看完整回答
反對(duì) 回復(fù) 2016-11-15
  • 1 回答
  • 0 關(guān)注
  • 1421 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)