一起使用 jQuery 和原型时出现此错误。我为 magento 中的运费计算模块编写了自定义 javascript,但无法在 firebug 控制台中解决此错误。任何知道解决此问题的提示的人,请写在这里。
TypeError: this.toPaddedString is not a function
[Break On This Error]
return this.toPaddedString(2, 16);
这是我使用的 JS,但没有对原型进行任何更改,但原型仍然出现错误。
( function($) {
// we can now rely on $ within the safety of our "bodyguard" function
$(document).ready( function() {
$('.s_code').change(function() {
// remove all previous selections
$('.option_all_box').attr('checked', false);
$('.option_all').val('0');
// hide all divs
$('.option_top').hide();
// show appropriate div & select first option
if($(this).val() == 'A')
{
$('.option_s').fadeIn();
$('.s_first').attr('checked', true);
}
else if ($(this).val() == 'B')
{
$('.option_p').fadeIn();
$('.p_first').attr('checked', true);
}
});
$('#frm_calculate').change(function() {
// ajaxify the calculate
// submit the form
$('#totalship').html('Please wait, Recalculating...');
formdata2 = $("form #frm_calculate").serialize();
var posting = $.post('calculate.php', formdata2, 'json');
posting.done(function( data ) {
//alert(data);
if(data.error)
{
//$('#totalship').html("Error!");
if(data.error.errorMessage == 'Please enter a valid amount.')
{
$('#totalship').html('Please enter a valid amount for extra cover (greater than zero)');
}
else
{
$('#totalship').html(data.error.errorMessage);
}
}
else
{
var result = data.postage_result;
thisqty = <?php echo $qtyArray[$i];?> ;
str = result.service + '<br>' + result.delivery_time + '<br>' + result.total_cost*thisqty;
// loop over the cost breakdown
//alert($(result.costs.cost).size());
listsize = $(result.costs.cost).size();
str = str + "<table width='100%'>";
if (listsize > 1)
{
$.each(result.costs.cost, function(key,value) {
str = str +'<tr><td width="50%">'+ value.item + '</td><td width="50%" style="text-align: right;">$' + value.cost*thisqty + '</td></tr>';
});
}
else if (listsize == 1)
{
value = result.costs.cost;
str = str + '<tr><td width="50%">'+value.item + '</td><td width="50%" style="text-align: right;">$' + value.cost*thisqty + '</td></tr>';
}
//Get variable from javascript back into this file's PHP code
var sendtoget1 = result.total_cost;
var sendtoget = sendtoget1; //*thisqty
var posting2 = $.post('sendtoget.php', sendtoget , 'text');
posting2.done(function( data ) {
//alert(data);
});
str = str + "</table>";
$('#totalship').html(str);
$('#totalship').fadeIn();
}
});
});
} );
} ) ( jQuery );
谢谢