JQUERY/AJAX请求未通过且发生冲突 [英] JQUERY/ AJAX Request not going through and conflicts
问题描述
我在页面中包含了联系表格.在同一页面中,我有一个脚本,该脚本根据下拉列表的值获取价格.现在,当我尝试提交联系消息时,我与价格脚本发生冲突.基本上,它尝试运行它,我不知道为什么.此外,提交时的联系表单永远无法使用...我只是打开了一个新页面,并显示了URL ..?message = blablabla知道出了什么问题吗?
I have included a contact form in my page. In the same page I have a script that gets prices depending on the value of a dropdown. Now when I try to submit the contact message I have a conflict with the script for prices. Basically it tries to run it and I have no clue why. Also the contact form when submitted never works...I just get a new page to open with URL..?message=blablabla Any idea what is going wrong?
我正在使用Laravel 4.2,因此您看到的路由将重定向到我的php函数.这是 JSfiddle ,这是php代码:
I am working on Laravel 4.2 and so the route you see redirects to my php function. Here is the JSfiddle and here is the php code:
public function postSendMessage() {
echo "<span class=\"alert alert-success\" >Your message has been received. Thanks!</span><br><br>";
}
推荐答案
取消点击,以便表单不提交
Cancel the click so the form will not submit
$("button#send").click( function(evt){
evt.preventDefault();
新错误,表单具有联系人ID,而不是类
New error, form has an id of contact, not a class
data: $('form.contact').serialize(),
需要成为
data: $('form#contact').serialize(),
这篇关于JQUERY/AJAX请求未通过且发生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!