未捕获的ReferenceError:函数未定义,它标记
16lz
2021-01-22
I need to submit form through ajax but function not defined and i browser inspect element mark <DOCOTYPE HTML>
please find code below
我需要通过ajax提交表单,但函数未定义,我浏览器检查元素标记
<form method="post" id="search_form" action="" name="search">
<div>
<select name="car_id" id="car_id" class="form-control">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
</div>
<div>
<select name="km_id" id="km_id" class="form-control">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
</div>
<div class="col-sm-12" align="center" style="font-size: 20px;padding-top: 50px;padding-bottom: 150px;">
<input class="btn-danger" id="search_button" name="search" onclick="search_function('locations.php')" type="button" value="search" />
</div>
</div>
</form>
<div class="col-sm-1"></div>
<div class="col-sm-12">
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function search_function($responce) {
$("#syana").innerHTML = '<img align="center" style="width:100px;height: 100px;margin-right: 300px;" src="loading.gif" />';
$.ajax({
type: "POST",
url: $responce,
data: $("form").serialize(),
success: function(data) {
$("#search").html(data);
},
error: function() {
alert("fix the PHP!")
}
});
note that same function used in another page and run successsfully
请注意,在另一个页面中使用相同的功能并成功运行
2 个解决方案
#1
0
This is wrong
这是错的
<DOCTYPE HTML>
The corect one is
核心是
<!DOCTYPE html>
更多相关文章
- 使用表单字段值定制CSS属性。
- 在回发之前在Jquery LinkButton中验证表单(使用Html验证)
- HTML表单学习1——表单基础
- 关于INPUT的autocomplete="off" 属性(浏览器表单默认的记忆功能)
- 9.1.4 前端 - HTML body标签 - 标题,段落,分割线,换行,特殊符号,列
- 我怎么能用javascript编写这个简短的函数?
- 你能告诉为什么javascript函数没有在profile.php的提交按钮中执
- JQuery函数不能用于初始触发器
- html5: 新特性(表单)