问题
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