AJAX form submission using ExtJS and ASP.NET MVC

强颜欢笑 提交于 2020-01-07 06:40:33

问题


I am working with ASP.NET MVC and have a view page with a simple text box and button to accompany it. I want AJAX to submit the form when the user clicks the search button. The response (search results) will be returned and displayed in a content div on the same page.

I have done this successfully with JQuery, but I need the same functionality in ExtJS.

Here is the JQuery (the form id is #helpsearchbox and #helpcontent is the id of the content div I want the results to be loaded into):

    $(function() {
        $("#helpsearchbox form").submit(function(e) {
            $.post($(this).attr("action"),
                        $(this).serialize(),
                        function(data) {
                    $("#helpcontent").html(data);
                        });
            e.preventDefault();
        });
    });

Can someone please help me write the equivalent function in ExtJS? Many thanks!


回答1:


Nevermind guys, I figured it out.

Ext.onReady(function() {
    Ext.get('formid').on('submit', function(e) {
                e.preventDefault();
                var content = Ext.get('targetdiv');
                content.load({
                    url: 'controllermethod',
                    params: 'q=' + Ext.get('textboxid').dom.value,
                    text: 'Searching...'
                });

                content.show();
            });
});



来源:https://stackoverflow.com/questions/3450368/ajax-form-submission-using-extjs-and-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!