jquery - this.toPlatedString 不是函数原型(prototype)

标签 jquery ajax magento prototype

同时使用 jQuery 和原型(prototype)时出现此错误。我为 magento 中的运输计算模块编写了自定义 javascript,但无法在 firebug 控制台中解决此错误。任何知道解决此问题提示的人,请写在这里。

TypeError: this.toPaddedString is not a function
[Break On This Error]   

return this.toPaddedString(2, 16);

这是我使用的JS,但没有对原型(prototype)进行任何更改,仍然从原型(prototype)中出现错误。

( 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 );

谢谢

最佳答案

抱歉回复晚了,但我遇到了同样的错误,但情况略有不同。当我进行 ajax 调用时,我的数据格式不正确。我最终做了 $.ajax(..., data: {key:value},...) 并且它最终成功了。

这是我在谷歌上搜索该错误时出现的 HitTest 门帖子,因此我认为我应该分享,以防其他人遇到同样的情况。

关于jquery - this.toPlatedString 不是函数原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16455678/

相关文章:

php - 清理 jsonp 回调的最佳方法?

jquery - 即使设置了超时,也无法使 jQuery ajax 调用持续超过 4 分钟,并出现 net::ERR_EMPTY_RESPONSE 错误

magento - 在 Magento 中将所有核心文件覆盖到本地

javascript - 将最小 z-index 设置为 jquery datepicker

javascript - 如何将window.onload附加到jquery中的特定页面

jquery - 一个 jquery 代码问题

php - 根据我的要求更改客户端浏览器中的图像

jquery - 将 JSON 从操作类传递到 JSP,而不在 struts 中使用 Ajax

magento - "Parent Role id ‘G1’ 不存在”以管理员身份登录时显示错误消息

Magento:以编程方式设置免费送货