once registered user click on button in view page we are creating new product and displaying that information in pop up as below
button code : [ full code : https://pastebin.com/da60SSWH ]
<button onclick="return setproductlogin(\'<?php echo
Mage::registry("current_product")->getId()?>\', event);setrequestlogin();"
id="submit-editorApply-{{rand}}">save design</button>
image url script [ full code : https://pastebin.com/19K43TyR ]
saveImageDefaultUrl : '<?php echo Mage::helper('aitcg')-
>getSecureUnsecureUrl(Mage::getUrl('aitcg/ajax/createImageDefault',array('id' =>
Mage::registry("current_product")->getId()))); ?>',
but if guest click on same button, its creating new product , but its redirecting to another page , but we want to display that message in pop up.... [ controllers : https://pastebin.com/9wsgufJX ]
1 Answer 1
I think you will require to add jQuery for this. Try adding below jquery code in your login popup "Login into your Account 4"
Add below code after this line,
var ajaxLoginForm = new VarienForm('ajaxlogin-login-form', true);
jQuery("#ajaxlogin-login-form").submit(function(e) {
e.preventDefault();
if (ajaxLoginForm.validator.validate()) {
jQuery.ajax({
type: "POST",
url: jQuery('#ajaxlogin-login-form').attr('action'),
}).done(function(result) {
alert(result);
}).fail(function() {
alert('There is some error saving your design.');
});
}
});
-
check updated code, you need to add the code after line
var ajaxLoginForm = new VarienForm('ajaxlogin-login-form', true);Jaimin Sutariya– Jaimin Sutariya2017年04月11日 09:15:12 +00:00Commented Apr 11, 2017 at 9:15 -
sorry, in a hurry to reply you, i didt observed , updated as you suggested, pastebin.com/XVacqNhgBaby in Magento– Baby in Magento2017年04月11日 09:17:15 +00:00Commented Apr 11, 2017 at 9:17
-
Please use
ajaxLoginForminstead ofmyformcheck updated codeJaimin Sutariya– Jaimin Sutariya2017年04月11日 09:19:14 +00:00Commented Apr 11, 2017 at 9:19 -
updated ajaxLoginForm codeBaby in Magento– Baby in Magento2017年04月11日 09:20:41 +00:00Commented Apr 11, 2017 at 9:20
-
The code is not working because you need to add
idto your form.<form action="<?php echo $this->getUrl('example/amasty/createSimpleProductAndRedirect', array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'), 'id' => Mage::registry('current_product')->getId())) ?>" id="ajaxlogin-login-form">Jaimin Sutariya– Jaimin Sutariya2017年04月11日 09:24:43 +00:00Commented Apr 11, 2017 at 9:24