Syntax error: Illegal return statement in JavaScript

后端 未结 6 1482
南方客
南方客 2021-02-04 23:25

I am getting a really weird JavaScript error when I run this code:



        
6条回答
  •  盖世英雄少女心
    2021-02-04 23:34

    If you want to return some value then wrap your statement in function

    function my_function(){ 
    
     return my_thing; 
    }
    

    Problem is with the statement on the 1st line if you are trying to use PHP

    var ask = confirm ('".$message."'); 
    

    IF you are trying to use PHP you should use

     var ask = confirm (); //now message with be the javascript string!!
    

提交回复
热议问题