Ajax in Magento can be pretty troublesome.Because you will need to take controllers and layout into account.And I almost used up a whole day trying to make ajax work. Here are some of the steps I’d like to share so that you will not waste lots of your time, before making this work
.
Let’s first know in Magento terms what we need.
Archive for the ‘ Ajax ’ Category
Working with AJAX in Magento
Posted on November 17, 2009 by Subesh Pokhrel | 5 Comments
Ajaxified File Uploader Using IFrame
Posted on July 22, 2008 by Subesh Pokhrel | 2 Comments
Today, while writing a code for AJAX file uploader, I was trying to do with [wiki]SALAJAX[/wiki]. But, with SALAJAX I could not manage to send the headers for $_FILES. So I thought of an alternative. And the alternative was to load the action page of the form on [wiki]IFrame[/wiki], whose display would be hidden and the work for uploading the file will be done on the background without refreshing the page. Yeha.. Its not [wiki]AJAX[/wiki], but it gives a user the feel of asynchronous working on the page. So, my code is Asynchronous Feel Without Javascript and XML (AFWJAX). What do think about this?
So, Here’s the code.The code below is for the form.
<form action="iframeinc.php" method="post" enctype="multipart/form-data" id="uploadform" target="iframe" name="uploadform"> File: <input name="pic" type="file" id="pic" style="margin-right:50px;" /> <br /> <input type="submit" name="Submit" value="Upload" /><br /> <iframe name="iframe" src="iframeinc.php" width="200" height="500" style="display:none;"> </iframe> </form>