如何通过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

通过以上链接一次

智能推荐

注意!

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



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

赞助商广告