Store in DB using AJAX - Magento

JS
--------------
var designInitialArray = {};
designInitialArray['template_id'] = document.getElementById('customer_template_id').value;
designInitialArray['design_code'] = design_code;
designInitialArray['product_id'] = product_id;
designInitialArray['customer_id'] = customer_id;
var designInitial_jsonString = JSON.stringify(designInitialArray);

$.ajax({
    type: "POST",
    url: "productdesigner/tool/customer_design_initialize/",
    data: {data: designInitial_jsonString},
    success: function (oup) {
        alert(oup);
    }
});


CONTROLLER ACTION
-------------------
Mage::getModel('productdesigner/customerdesign')->customer_design_initialize($_POST['data']);


MODEL
-------------

$items = array();
$oldarray = json_decode($data);
foreach ($oldarray as $key => $item) {
    $items[$key] = $item;
}


$hot_spot = Mage::getModel('productdesigner/itemhotspot');
$hot_spot->setData($items);

Popular posts from this blog

[Solved] Hive installation error: java.net.URISyntaxException: Relative path in absolute URI

Install Android SDK in centOs

Installing arules package (Association Rules) in R