如何通過javascript函數將spring表單作為參數傳遞給ajax調用?

[英]How to pass a spring form as an argument to ajax call through javascript function?


I have a Spring Form which has two buttons in JSP file.

我有一個Spring表單,在JSP文件中有兩個按鈕。

<input type="button" onclick="saveTopicsActions(this.form)" class="btn primary publish border16" id="saveBtn" value="Save"/>
                <input type="submit" class="btn primary publish border16" id="publishBtn" value="Publish"/>

The onClick() function of Save button should take this form as an argument and pass the same to an Ajax Call.

“保存”按鈕的onClick()函數應將此形式作為參數並將其傳遞給Ajax調用。

function saveTopicsActions(form){
            jsonData={};
            jsonData = form;
            VR.appendToJSObject(jsonData);
            var jqxhr = $.post(saveTopicsActionsURL, jsonData, function(returnString) {
                if (returnString == 'true'){
                    showAutoSaveMessage();
                }else{
                    alert(returnString);
                    window.location.reload();
                }
            });
            jqxhr.error(function(data){
                //This one is highly unlikely
                alert("There was a problem  - please contact support");
                window.location.reload();
            });

But, This is throwing below the javascript exception

但是,這是拋出javascript異常

TypeError: 'stepUp' called on an object that does not implement interface HTMLInputElement

TypeError:'stepUp'調用未實現接口HTMLInputElement的對象

1 个解决方案

#1


0  

don't send a form it is DOM element, try sending the values in ajax, form a JSONobject and send as parama in the AJAX call.

不發送它是DOM元素的表單,嘗試在ajax中發送值,形成一個JSONobject並在AJAX調用中作為parama發送。

TypeError: 'stepUp' called on an object that does not implement interface HTMLInputElement

TypeError:'stepUp'調用未實現接口HTMLInputElement的對象

go through the above link once

通過以上鏈接一次


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/02/04/7deef516d9ee61817cb4af2e5bb8995b.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com