<head>与</head>中间调用
html代码
<form class="my-4" onsubmit="return submsg(this);">
<input type="text" name="contacts" required="" id="contacts" class="form-control" placeholder="请输入联系人" />
<input type="text" name="mobile" required="" id="mobile" class="form-control" placeholder="请输入联系人手机" />
<textarea name="content" id="content" class="form-control" placeholder="请输入留言内容"></textarea>
{pboot:if({pboot:msgcodestatus})}
<input type="text" name="checkcode" required="" id="checkcode" class="form-control" placeholder="请输入验证码" />
<img title="点击刷新" class="codeimg" style="height:33px;" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" />
{/pboot:if}
<button type="submit" class="btn btn-info mb-2">提交留言</button>
</form>
底部</body>前
<scirpt> //ajax提交留言 function submsg(obj){ var url='{pboot:msgaction}'; var contacts=$(obj).find("#contacts").val(); var mobile=$(obj).find("#mobile").val(); var content=$(obj).find("#content").val(); var checkcode=$(obj).find("#checkcode").val(); $.ajax({ type: 'POST', url: url, dataType: 'json', data: { contacts: contacts, mobile: mobile, content: content, checkcode: checkcode }, success: function (response, status) { if(response.code){ alert("谢谢您的反馈,我们会尽快联系您!"); location.href="https://www.31jz.com/"; //提交后跳转链接 $(obj)[0].reset(); }else{ if(response.tourl!=""){ if(confirm(response.data+'是否立即跳转登录?')){ location.href=response.tourl; } } $('.codeimg').click();//更新验证码 } }, error:function(xhr,status,error){ alert('返回数据异常!'); } }); return false; } </scirpt>
本文地址:https://www.31jz.com/jzjc/1067.html