1. 程式人生 > >Uncaught ReferenceError: set_img_func is not defined at HTMLInputElement.onclick

Uncaught ReferenceError: set_img_func is not defined at HTMLInputElement.onclick

問題:

Uncaught ReferenceError: set_img_func is not defined
at HTMLInputElement.onclick ((index):476)

解決:

<td>
    <label>
        <input tabindex="1" type="radio" style="vertical-align:middle;" id="set_curr_img_radio" name="radio" value=${image_obj.id} onclick="set_img_func()">
        <span style="vertical-align:middle;">當前使用映象</span>
    </label>
</td>




<script>
$(document).ready(function(){
    $('.ProjId').click(
        function (){
            projId=$(this).attr('value');
            oldProjId=$.cookie('projId');
            if(projId!=oldProjId){
                $.cookie('projId', projId, {path: '/', domain: null});
                window.location.reload();

             }
        }
    );
    //這麼寫就解決了,不要用function set_img_func(){some code}:
    set_img_func = function (){
        var radio_val
        $('input:radio').each(
            function(){
                if(this.checked){
                    radio_val = $(this).val();
                    $.ajax({
                        url:'${SITE_URL}image_register/',
                        type:'POST',
                        data: JSON.stringify({img_id:$(this).val()}),
                        headers:{'X-CSRFToken':$.cookie('csrftoken')},
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function(result) {
                            if (result.code=="200"){
                                alert('設定成功!')
                            }
                            else {
                                //alert('設定失敗!');
                            }
                        },
                         error: function () {
                           alert('傳送失敗!');
                         }
                    });
                }

            }
        );
    };
});
</script>

相關推薦

Uncaught ReferenceError: set_img_func is not defined at HTMLInputElement.onclick

問題: Uncaught ReferenceError: set_img_func is not defined at HTMLInputElement.onclick ((index):476) 解決: <td> <label&g

Uncaught ReferenceError: xxx is not defined at HTMLButtonElement.onclick

Uncaught ReferenceError: xxx is not defined at HTMLButtonElement.onclick html中呼叫js方法一直報錯,找了半天,最後發現html引入外部js庫的時候居然是這樣寫的 <script src="h

Uncaught ReferenceError: require is not defined at ES6.js:1 (anonymous) @ ES6.js:1

在匯入whatwg-fetch時遇到了這個問題 我們使用babel把es6轉化為es5的時候,會把import 轉化為 var _es = require('whatwg-fetch'); 採用require引用的commomjs形式。  瀏覽器端不識別r

Uncaught ReferenceError: jQuery is not defined

位置 如果 list ack ont erro tails jquer .net 頁面調試時,明明引入了JQ文件,卻一直提示Uncaught ReferenceError: jQuery is not defined錯誤。 轉自:http://blog.csdn.net/b

報錯:Uncaught ReferenceError: input is not defined

ont png pan uncaught AC cau alt style ref 報錯如下: 原因:input 元素找不到,錯誤代碼如下: 正確如下:必須加 ‘ ’ 或 “ ” 報錯:Uncaught ReferenceError: input is not

解決:Uncaught ReferenceError: jQuery is not defined

在我寫好後臺程式碼準備在登陸頁面登陸的時候發現的錯誤,但是我報錯相關的js檔案都正確匯入了的 百度了後,參照如下貼子: https://www.aliyun.com/jiaocheng/984428.html 其中說到:頁面jQuery.js的引用位置問題,如果匯入了其它與jque

關於 eval 的報錯 Uncaught ReferenceError: False is not defined

var obj ={'id': 16, 'name': '管理員', 'delflag': False, 'grade': 1000000.0}VM3614:1 Uncaught ReferenceError: False is not defined at <anonymous>:1:47(an

Uncaught ReferenceError: app is not defined

Uncaught ReferenceError: app is not defined angular.min.js:80 Error: [$injector:unpr] http://errors.angularjs.org/1.2.9/$injector/unpr?p0=upload

初識React專案遇到的坑(Uncaught ReferenceError: Set is not defined

**前言:每次在android、rn跟h5中切換的時候,程式碼總是會鬧各種笑話,比如在rn中變數都是包含在“{}”只有一層花括號,但是在vue中“{{}}”會有兩層花括號,樣式的話rn是駝峰fontSize這種,但在h5中是font-size,然後在android中老喜歡把一個字串定義為

js報錯:Uncaught ReferenceError: xxmethod is not defined

碰到bug的時候都會覺得很奇怪 今天在一個js方法中寫了一句程式碼,測試沒問題 var ww=<c:out value="${SHOWTYPE}"/> 但是換了一個使用者B登入,卻報另一個js方法沒有定義 反覆嘗試了半天,就是因為在第一個方法中新增的那句程

Uncaught ReferenceError: jp2 is not defined,用jsonp抓取qq音樂總是說回撥函式沒有定義

問題如下參考連結:https://segmentfault.com/q/1010000010051040 用jsonp抓取qq音樂總是說回撥函式沒有定義, 我的要實現時候的步驟 1。第一步 我要實現的目的 問題:如題 我的部分程式碼: import originJSON

UEditor 報錯:Uncaught ReferenceError: UE is not defined; Uncaught ReferenceError: UM is not defined

Uncaught ReferenceError: UE is not defined Uncaught ReferenceError: UM is not defined 百度的富文字編輯器Ueditor,有兩個版本,一個是全功能版(簡稱UE),另一個是

獲取jQuery物件 Uncaught ReferenceError: jQuery is not defined(…) 的解決辦法

1. 將jQuery引用寫在最前面 2.將自己的外掛函式所在檔案的引入位置放在jQuery引用之後 若是還沒有解決: 把呼叫執行程式碼放在$(function(){寫執行程式碼})裡面,保證事件的發生是在頁面檔案載入完成之後,避免jQuery檔案引用混亂導致出錯  比

百度地圖API使用遇問題-ReferenceError: BMapLib is not defined

解決過程: 1st. 在 test.html 查詢 BMapLib 字串。     都哪裡出現過,本文件中是否定義,是否存在中英文輸入法問題,是否在定義時多了空格等等。     結果是,本文件中未定義 BMapLib,僅引用一

jquery.easyui.min.js:ncaught ReferenceError: jQuery is not defined

最近寫一個jsp頁面,總是出現: jquery.easyui.min.js:325 Uncaught ReferenceError: jQuery is not defined 就是jquery沒有引入的錯,程式碼是這樣的: <script type=

babel/preset-env ReferenceError : regeneratorRuntime is not defined

> [email protected] start /home/lmx/Workspace/react-ssr > node ./build/bundle.js webpack:

關於 Module build failed: ReferenceError: Promise is not defined 錯誤

webpack打包的時候報錯:Module build failed: ReferenceError: Promise is not defined</pre><pre name="code" class="java">ERROR in ./~/cs

vue ssr 報錯 ReferenceError: window is not defined

這是因為首先使用node服務端進渲染的,而node端不存在window物件解決辦法如下 :把需要執行系統物件的程式碼放到mounted生命週期裡,待node服務端渲染完成之後則可以正常使用啦注:既然採用服務端渲染了,儘可能避免使用系統物件元素啦我們所有的資料不能放在vue中的

Android studio 引入 weex 中由.vue打包的.js檔案,ReferenceError: Vue is not defined錯誤

按照weex官網給出的配置,weex_sdk 版本是 0.5.1,就是由於這個版本太低,對vue.js1不支援導致的, 切換到最新sdk版本即可 還有的童鞋可能會遇到 WXSDKEngine.initialize 初始化失敗,有可能因為配置不正確 /**  * 注意要在Ma

微信小程式----連等報錯(ReferenceError: xxxxx is not defined

出現的錯誤 ReferenceError: xxxxx is not defined 出現的場景 在初始化countX ,countY ,countZ 這三個變數都為0時,在JS