使用ExtJS的和ASP.NET MVC AJAX表单提交 [英] AJAX form submission using ExtJS and ASP.NET MVC
问题描述
我的ASP.NET MVC工作,有一个简单的文本框和按钮视图页面陪它。我想AJAX来当用户点击搜索按钮提交表单。响应(搜索结果)将返回并显示在同一页面上的内容DIV。
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.
我已经用jQuery成功地这样做,但我需要在ExtJS的相同的功能。
I have done this successfully with JQuery, but I need the same functionality in ExtJS.
下面是JQuery的(在表单ID是#helpsearchbox 和 #helpcontent是内容的ID的div 我要的结果被加载到):
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();
});
});
有人可以帮我写ExtJS的同等功能?非常感谢!
推荐答案
没关系家伙,我想它了。
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();
});
});
这篇关于使用ExtJS的和ASP.NET MVC AJAX表单提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!