Skip to main content
improve code
Source Link
Shorabh
  • 1.5k
  • 12
  • 19

Below i have add new ajax request url in code. please review it

jQuery( "#margin_percent" ).change(function() {     
    var $_this = jQuery( this );
    var store_id = 0;
    /* margin is controller name. file name is like "marginController.php" & getPercent is function */
    new Ajax.Request('ajaxdata/margin/getPercent/', {
        method: 'post''get',
        parameters: {
            storeId: store_id,
            margin: $_this.val(),
            productId: jQuery('#productcreator_product_id').val(),
        },
        onSuccess: function (transport) {
            var response = JSON.parse(transport.responseText);

            jQuery("#special_price").val(response['special_price']);
        },
        onFailure: function () {

        }
    });
});

Below i have add new ajax request url in code. please review it

jQuery( "#margin_percent" ).change(function() {     
    var $_this = jQuery( this );
    var store_id = 0;
    /* margin is controller name. file name is like "marginController.php" & getPercent is function */
    new Ajax.Request('ajaxdata/margin/getPercent/', {
        method: 'post',
        parameters: {
            storeId: store_id,
            margin: $_this.val(),
            productId: jQuery('#productcreator_product_id').val(),
        },
        onSuccess: function (transport) {
            var response = JSON.parse(transport.responseText);

            jQuery("#special_price").val(response['special_price']);
        },
        onFailure: function () {

        }
    });
});

Below i have add new ajax request url in code. please review it

jQuery( "#margin_percent" ).change(function() {     
    var $_this = jQuery( this );
    var store_id = 0;
    /* margin is controller name. file name is like "marginController.php" & getPercent is function */
    new Ajax.Request('ajaxdata/margin/getPercent/', {
        method: 'get',
        parameters: {
            storeId: store_id,
            margin: $_this.val(),
            productId: jQuery('#productcreator_product_id').val(),
        },
        onSuccess: function (transport) {
            var response = JSON.parse(transport.responseText);

            jQuery("#special_price").val(response['special_price']);
        },
        onFailure: function () {

        }
    });
});
Source Link
Shorabh
  • 1.5k
  • 12
  • 19

Below i have add new ajax request url in code. please review it

jQuery( "#margin_percent" ).change(function() {     
    var $_this = jQuery( this );
    var store_id = 0;
    /* margin is controller name. file name is like "marginController.php" & getPercent is function */
    new Ajax.Request('ajaxdata/margin/getPercent/', {
        method: 'post',
        parameters: {
            storeId: store_id,
            margin: $_this.val(),
            productId: jQuery('#productcreator_product_id').val(),
        },
        onSuccess: function (transport) {
            var response = JSON.parse(transport.responseText);

            jQuery("#special_price").val(response['special_price']);
        },
        onFailure: function () {

        }
    });
});