AJAX form submission using ExtJS and ASP.NET MVC

2019-08-26 08:50发布

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条回答
爷的心禁止访问
2楼-- · 2019-08-26 09:44

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();
            });
});

查看更多
登录 后发表回答