繁体   English   中英

ReferenceError:未定义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>  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM