1
<form onsubmit=
"return submsg(this);"
>
2
联系人<input
type
=
"text"
name=
"contacts"
required
id
3
手 机<input
"mobile"
4
内 容<textarea name=
"content"
></textarea>
5
验证码<input
"checkcode"
6
<img title=
"点击刷新"
src=
"{pboot:checkcode}"
onclick=
"this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);"
/>
7
<button
"submit"
>提交留言</button>
8
</form>
01
<script>
02
//ajax提交留言,由于涉及到提交地址标签的解析,JS需要放在html文件中
03
function
submsg(obj){
04
var url=
'{pboot:msgaction}'
; //如果是自定义表单则使用地址{pboot:form fcode=*}
05
var contacts=$(obj).
find
(
"#contacts"
).val();
06
var mobile=$(obj).
"#mobile"
07
var content=$(obj).
"#content"
08
var checkcode=$(obj).
"#checkcode"
09
10
$.ajax({
11
:
'POST'
,
12
url: url,
13
dataType:
'json'
14
data: {
15
contacts: contacts,
16
mobile: mobile,
17
content: content,
18
checkcode: checkcode
19
},
20
success:
(response, status) {
21
if
(response.code){
22
alert(
"谢谢您的反馈,我们会尽快联系您!"
);
23
$(obj)[0].reset();
24
}
else
{
25
alert(response.data);
26
27
28
error:
(xhr,status,error){
29
'返回数据异常!'
30
31
});
32
return
false
;
33
34
</script>
皖公网安备 34010402701667号