查看源码打印代码帮助 01<script> 02//ajax提交留言,由于涉及到提交地址标签的解析,JS需要放在html文件中 03functionsubmsg(obj){ 04var url='{pboot:msgaction}'; //如果是自定义表单则使用地址{pboot:form fcode=*} 05var contacts=$(obj).find("#contacts").val(); 06var mobile=$(obj).find("#mobile").val(); 07var content=$(obj).find("#content").val(); 08var checkcode=$(obj).find("#checkcode").val(); 09 10$.ajax({ 11type: 'POST', 12url: url, 13dataType: 'json', 14data: { 15contacts: contacts, 16mobile: mobile, 17content: content, 18checkcode: checkcode 19}, 20success: function(response, status) { 21if(response.code){ 22alert("谢谢您的反馈,我们会尽快联系您!"); 23$(obj)[0].reset(); 24}else{ 25alert(response.data); 26} 27}, 28error:function(xhr,status,error){ 29alert('返回数据异常!'); 30} 31}); 32returnfalse; 33} 34</script> |