如果你想用ajax提交magento的表单数据,可以尝试这种写法

<form name="sampleform" id="sampleform" οnsubmit="new Ajax.Updater({success:'sampleform’}, '<?php echo $this->getUrl('yourmoduleCompanyName/index/moduleIndexControllerAction') ?>', {asynchronous:true, evalScripts:false, onComplete:function(request, json){Element.hide('sampleform');Element.show('sampleform');}, onLoading:function(request, json){}, parameters:Form.serialize(this)}); return false;"  method="post">

这样讲表单的数据提交到你所指定的控制器中

<?php echo $this->getUrl('yourmoduleCompanyName/index/moduleIndexControllerAction') ?>

magento内置的Ajax类会帮你异步处理所需的请求,详细的参数可参加Ajax类!

本文参考自:http://blog.magentoconnect.us/use-ajax-in-magento/

Logo

更多推荐