引用错误: 未定义 onclick 函数
ReferenceError: onclick function is not defined
我得到了一个"ReferenceError:函数未在saveRoute函数上定义"。对我来说一切似乎都是对的,但我无法弄清楚问题所在。
以下是相关代码。
<script type="text/javascript">
var array = routeobj;
function saveRoute(){
var json = JSON.stringify(array)
$.ajax({
url : "http://192.168.1.9:11123/runornot/drawtrack",
type: "POST",
dataType:'json'
data : {json:json}
{"routeJson": json },
console.log("hellohelloworldolr");
success: function(data, textStatus, jqXHR)
{ //data - response from server
console.log("checkin success"); },
error: function (jqXHR, textStatus, errorThrown)
{
}});}
</script>
并在 HTML 中
<a href="#" onClick="saveRoute();" id="savebtn" class="ui-btn ui-corner-all ui-btn-a">Save</a>
<script type="text/javascript">
var array = routeobj;
function saveRoute(){
var json = JSON.stringify(array) // <--- best practice would require a semicolon here
$.ajax({
url : "http://192.168.1.9:11123/runornot/drawtrack",
type: "POST",
dataType:'json' // <--- missing a comma
// the structure doesn't make any sense starting here...
data : {json:json} // <--- should be a comma here?
// missing property name?
{"routeJson": json },
// is this supposed to be the body of a function?
console.log("hellohelloworldolr");
// things start making sense again here...
success: function(data, textStatus, jqXHR)
{ //data - response from server
console.log("checkin success"); },
error: function (jqXHR, textStatus, errorThrown)
{
}});}
</script>
相关文章:
- onclick函数需要双击,因为类分配延迟
- Javascript onclick函数会立即调用(而不是在单击时调用)
- jquery Onclick函数带有导致双击的回调排序函数
- 使用element简化onclick函数
- 在React中,为什么我必须绑定onClick函数而不是调用它
- 如何从onclick函数设置全局变量并将其传递给另一个JS文件
- 在onclick函数中传递多个参数
- 如何将onclick函数更改为具有多个函数
- 将OnClick函数设置为<ul>,最后一个ul是擦除第一个ul-s
- 指定一个具有静态值的onclick函数
- Onclick函数更改为所有更改元素的相同函数
- 将php变量传递给onclick函数
- 请帮我完成js中按钮的onclick函数
- .hasClass 在 onclick 函数中不起作用,但删除和添加类函数可以
- Jquery移动转换复选框在Jquery onclick函数()中第二次选中不起作用
- 使用“;这个“;在onclick函数中
- 如何在按Enter键后调用onclick函数
- jQuery onclick 函数:未定义不是一个函数
- 如何在 OnClick 函数中传递字符串参数
- OnClick函数仅在第二次单击时起作用