2026 Executive BenchmarkMid-Market Enterprise Modernization: How leaders across unify Commerce, Odoo ERP & AI in 90 days.
PHP DEVELOPMENT

Custom Form Data Save Ajax with validation in Magento

First Create test.php file copy all code and paste in file .Then run on localhost,fisrt time load file thane save data without load save data only one click. YOUR Custom Form : Ema...

Akshar Group Technologies
Dec 25, 2020
1 min read
Verified Source

First Create test.php file copy all code and paste in file .Then run on localhost,fisrt time load file thane save data without load save data only one click. YOUR Custom Form :

Email request for lowest price of getName()?>

First Name

Last Name

Email Address

* Required Fields

php
<button type="submit" title="__('Submit') ?>" class="button">__('Submit') ?>
<img class="lazyload" decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-orig-src="getSkinUrl("images/opc-ajax-loader.gif")?>">

YOUR script :
<?php
//var dataForm = new VarienForm('lowest-form-validate', true);
//<![CDATA[
var formId = 'lowest-form-validate';
var myForm = new VarienForm(formId, true);
//var postUrl = '';
var postUrl = "";
function doAjax() {
if (myForm.validator.validate()) {
new Ajax.Updater(
{ success:'formLowestSuccess' }, postUrl, {
method:'post',
asynchronous:true,
evalScripts:false,
onComplete:function(request, json) {
Element.hide(formId);
Element.show('formLowestSuccess');
},
onLoading:function(request, json){
Element.show('formLoader');
},
parameters: $(formId).serialize(true),
});
}}
new Event.observe(formId, 'submit', function(e){
e.stop();
doAjax();
});

//end of javascript code
}}
?>
Share this playbook
LET'S BUILD WHAT'S NEXT

What's Holding Your Business Back?

Tell us where you want to go, what's getting in the way, and we'll help you figure out the technology to get there.

No sales pitch. Confidential strategic advisory.