首页 > 解决方案 > javascript - 意外的令牌?

问题描述

我想在上传照片时添加加载 gif。这是我的 JavaScript:

<script type="text/javascript">
    function call(tab) {
        $(".loading").html("<center><br><br><img src=\"icons/processing.gif\" /><br><br></center>").load(tab);

    }
</script>

这就是我调用函数的方式:

<div class="loading"></div>
    <div class="col-md-12">
        <div class="form-group">
            <input type="file" name="take_photo" id="take_photo" class="take-photo" onchange="submit(); call('survey_edit.php?id='<?$id;?>'&step=photo')">
            <label for="take_photo"><figure><img src="icons/camera.png"></figure> <span><?=v("take_photo");?>&hellip;</span></label>
        </div>
        <div class="form-group">
            <?=$f->input("back",v("back"),"type='button' onclick=\"window.location='?step=2&id=".$id."';\"","btn btn-warning");?>
            <?=$f->input("finish",v("finish"),"type='button' onclick=\"window.location='mysurvey.php';\" style='position:relative;float:right;'","btn btn-primary");?>
        </div>
    </div>

它显示以下错误:“Uncaught SyntaxError: Unexpected token ?”

谁能帮我这个?

标签: javascripthtmlcss

解决方案


您的 onchange 事件应如下所示:

onchange="submit(); call('survey_edit.php?id=<?=$id?>&step=photo')"


推荐阅读