未捕获的ReferenceError:magento站点中未定义jQuery

时间:2016-03-17 12:14:15

标签: javascript jquery database magento

我们正在使用以下脚本,在控制台中我们遇到了这些错误:

我们有magento site 1.9.0

我们提供了一个保存前端值的选项。

此处在前端,值未保存在数据库中。

jquery错误有问题吗?我跟着第一个回答这个链接:Uncaught ReferenceError: $ is not defined?但它确实对我有用

enter image description here

html代码

<span class="label qty" id="valueqty_<?php echo $assinproducts->getId(); ?>">
        <?php echo intval($assinproducts['qty']); ?>
    </span>

    <input type = "text" id = "qty_<?php echo $assinproducts->getId(); ?>" onkeydown="validateNumbers(event)" 
    name="stock" value="<?php echo intval($assinproducts['qty']); ?>" style="display:none;"/>

    <span class="label wk_action" id="edit_link_<?php echo $assinproducts->getId(); ?>">
        <img onclick="showField('<?php echo $assinproducts->getId(); ?>'); return false;" 
        src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>

    <p id="updatedqty_<?php echo $assinproducts->getId(); ?>" style = "display:none;color:red;">Updated</p><br/>

    <button id="update_button_<?php echo $assinproducts->getId(); ?>" class="button wk_mp_btn1" 
    onclick="updateField('<?php echo $assinproducts->getId(); ?>',<?php echo intval($assinproducts['qty']); ?>); return false;" style="display:none" >
        <span>
            <span style="font-size:12px;"><?php echo $helper->__('Update') ?></span>
        </span>
    </button>

    <button id="reset_button_<?php echo $assinproducts->getId(); ?>" type="reset" class="cancel" 
    onclick="hideReset('<?php echo $assinproducts->getId(); ?>'); return false;" style="display:none"></button>

脚本

<script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.jcarousel.min.js"></script>

<!-- to remove console js errors end -->


<script language="JavaScript" type="text/javascript" src="/js/jquery-1.2.6.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/jquery-ui-personalized-1.5.2.packed.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/sprinkle.js"></script>
<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>


<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js">
    function validateNumbers(e)
    {
        if (jQuery.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
            // Allow: Ctrl+A, Command+A
            (e.keyCode == 65 && ( e.ctrlKey === true || e.metaKey === true ) ) || 
            // Allow: home, end, left, right, down, up
            (e.keyCode >= 35 && e.keyCode <= 40)) {
                // let it happen, don't do anything
                return;
        }

        // Ensure that it is a number and stop the keypress
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    }

    var $wk_jq = jQuery.noConflict();

    (function($wk_jq){
            $wk_jq( "#special_from_date" ).datepicker({dateFormat: "yy-mm-dd"});
            $wk_jq( "#special_to_date" ).datepicker({dateFormat: "yy-mm-dd"});
            $wk_jq('#mpselecctall').click(function(event) {
            if(this.checked) {
                $wk_jq('.mpcheckbox').each(function() {
                    this.checked = true;      
                });
            }else{
                $wk_jq('.mpcheckbox').each(function() {
                    this.checked = false;           
                });         
            }
        });

        $wk_jq('body').delegate('.mp_edit','click',function(){
            var id=$wk_jq(this).attr("data-type");  
                    var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>');
                    if(dicision==true){         
                            var $type_id=$wk_jq(this).attr('data-type');                
                            window.location = "<?php echo $this->getUrl('mpassignproduct/index/edit/') ?>".concat("id/",id);    
                    }
        });

        $wk_jq('.mp_delete').click(function(){
                    var id=$wk_jq(this).attr("data-type");
                    var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>');
                    if(dicisionapp==true)
                            window.location = "<?php echo $this->getUrl('mpassignproduct/index/delete/') ?>".concat("id/",id);
            });

            $wk_jq('#mass_delete_butn').click(function(e){
                    var flag =0;
                    $wk_jq('.mpcheckbox').each(function(){
                            if (this.checked == true){
                                    flag =1;
                            }
                    });
                    if (flag == 0){
                            alert("<?php echo $helper->__(' No Checkbox is checked') ?>");
                            return false;
                    }
                    else{
                            var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>');
                            if(dicisionapp==true){
                                    $wk_jq('#form-customer-product-delete').submit();
                            }else{
                                    return false;
                            }
                    }
            });
    })($wk_jq);


    function hideReset(product_id)
    {
        var qtyId='#qty_'+ product_id;
        var editLink="#edit_link_"+ product_id;
        var updateButton="#update_button_"+ product_id;
        var resetButton="#reset_button_"+ product_id;

        $wk_jq(qtyId).hide();
        $wk_jq(editLink).show();
        $wk_jq(updateButton).hide();
        $wk_jq(resetButton).hide();
    }

    function showField(product_id)
    {
        var qtyId           = '#qty_'+ product_id;
        var editLink        = "#edit_link_"+ product_id;
        var updateButton    = "#update_button_"+ product_id;
        var resetButton     = "#reset_button_"+ product_id;

        $wk_jq(qtyId).show();
        $wk_jq(editLink).hide();
        $wk_jq(updateButton).show();
        $wk_jq(updateButton).prop('disabled', false);//just in case
        $wk_jq(resetButton).show();

        return false;
    }



    function updateField(product_id,assignqty)
    {

    //  alert("Hello! I am an alert box!!");
        var qtyId           = '#qty_'+ product_id;
        var valueId         = '#valueqty_'+ product_id;
        var updatedqty      = '#updatedqty_'+ product_id;
        var editLink        = "#edit_link_"+ product_id;
        var updateButton    = "#update_button_"+ product_id;
        var resetButton     = "#reset_button"+ product_id;
        var url             = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>';

        $wk_jq(qtyId).toggle();
        $wk_jq(editLink).hide();
        $wk_jq(updateButton).show();
        $wk_jq(resetButton).show();

        $qty = $wk_jq(qtyId).val();
        jQuery(valueId).html($qty);
        hideReset(product_id);

        var tmpQty = assignqty+parseInt($qty) ;

        new Ajax.Request(url, {
            method: 'post',
            parameters: {id: product_id, qty: tmpQty},
            onComplete: function (transport) {
            //  alert(tmpQty);
                jQuery(priceId).val($price);                
        jQuery(updatedqty).show().delay(2000).fadeOut();
                $updateButton.prop('disabled', false);
            }
        });
    }






</script>

完整文件的html和js代码:

<script type="text/javascript" src="/test/wp-content/themes/child/script/jquery.jcarousel.min.js"></script>

<!-- to remove console js errors end -->


<script language="JavaScript" type="text/javascript" src="/js/jquery-1.2.6.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/jquery-ui-personalized-1.5.2.packed.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/sprinkle.js"></script>
<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>








<?php
$helper=Mage::helper('mpassignproduct');
$isPartner= Mage::getModel('marketplace/userprofile')->isPartner(); 
if($isPartner==1){ ?>
    <script type="text/javascript">
    if (typeof jQuery == 'undefined'){
        document.write(unescape("%3Cscript src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
    }
    </script>
    <script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <div>   
        <div class="page-title">
            <h1><?php echo $helper->__('My Assign Product List') ?></h1>
        </div>
        <div class="wk_mp_design">
            <div class="block block-account">   
                <div class="block-title">   
                    <strong><span><h4><?php echo $helper->__('My Assign Product List'); ?></h4></span></strong>
                </div>
            </div>
            <div class="fieldset wk_mp_fieldset">
                <div class="grid">
                    <div class="hor-scroll">
                        <?php 
                            if(count($this->getCollection())==0): ?>        
                                <div class="fieldset wk_mp_fieldset">
                                    <div class="wk_emptymsg">
                                        <?php echo $helper->__('No Product Available') ?>
                                    </div>
                                </div>
                        <?php else: ?>
                            <form action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" method="post">
                                <table cellspacing="0" class="border wk_mp_list_table">
                                    <thead>
                                        <tr id="wk_mp_tr_heading">
                                            <th><span><?php echo $helper->__('Product Name') ?></span></th>
                                            <th><span><?php echo $helper->__('Date') ?></span></th>
                                            <th><span><?php echo $helper->__('Product Status') ?></span></th>
                                            <th><span>&nbsp;</span></th>
                                        </tr>
                                    </thead>
                                    <tbody class="wk_mp_body">
                                        <tr>
                                            <td>
                                                <input type="text" class="input-text" name="s" placeholder='<?php echo $helper->__('Search by product name') ?>' value="<?php echo $this->getRequest()->getParam('s')?>"/>
                                            </td>
                                            <td>
                                                <span class="wk_mp_td_span">
                                                    <?php echo $helper->__('From: ') ?>
                                                    <input name="from_date" id="special_from_date" class="input-text" value="<?php echo $this->getRequest()->getParam('from_date')?>" />
                                                </span>                             
                                                <span class="wk_mp_td_span">
                                                    <?php echo $helper->__('To: ') ?>
                                                    <input name="to_date" id="special_to_date" class="input-text" value="<?php echo $this->getRequest()->getParam('to_date')?>" />
                                                </span>
                                            </td>
                                            <td>
                                                <select name="prostatus" class="input-text">
                                                    <option value=""><?php echo $helper->__('All') ?></option>
                                                    <option value="1" <?php if($this->getRequest()->getParam('prostatus') == 1) echo 'selected="selected"'?>>
                                                        <?php echo $helper->__('Approved') ?>
                                                    </option>
                                                    <option value="2" <?php if($this->getRequest()->getParam('prostatus') == 2) echo 'selected="selected"'?>>
                                                        <?php echo $helper->__('Unapproved') ?>
                                                    </option>
                                                </select>
                                            </td>
                                            <td>
                                                <button class="button" title="Save" type="submit">
                                                    <span><span><span><?php echo $helper->__('Submit') ?></span></span></span>
                                                </button>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                            <form name="formmassdelete" id="form-customer-product-delete" method="post" action="<?php echo $this->getUrl('mpassignproduct/index/massdeletepro') ?>">
                                <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
                                <button id="mass_delete_butn" style="float: left;padding: 5px 5px 5px 0;" type="submit" title="Delete Sellers" class="button">
                                    <span><span>Delete Products</span></span>
                                </button>
                                <table cellspacing="0" class="border wk_mp_list_table wk_mp_list_container_table">
                                    <thead>
                                        <tr class="wk_content">
                                            <th class="wk_check_first_td">
                                                <span><input type="checkbox" id="mpselecctall" value="all" name="mpselecctall"></span>
                                            </th>
                                            <th class="wk_first_td">
                                                <span class="label "><?php echo $helper->__('Product Name')?></span>
                                            </th>
                                            <th>
                                                <span class="label name"><?php echo $helper->__('Price')?></span>
                                            </th>

                                            <th>
                                                <span class="label name"><?php echo $helper->__('SKU')?></span>
                                            </th>

                                            <th>
                                                <span class="label name"><?php echo $helper->__('Delivery Time')?></span>
                                            </th>

                                            <th>
                                                <span class="label name"><?php echo $helper->__('Replacement Guarantee')?></span>
                                            </th>

                                            <th>
                                                <span class="label qty"><?php echo $helper->__('Status')?></span>
                                            </th>  


                                            <th>
                                                <span class="label qty"><?php echo $helper->__('Qty.')?></span>
                                            </th> 


                                            <th>
                                                <span class="label qty"><?php echo $helper->__('Condition')?></span>
                                            </th> 

                                            <th>
                                                <span class="label"><?php echo $helper->__('Action')?></span>
                                            </th>   

                                        </tr>
                                    </thead>

                                    <tbody>
                                        <?php foreach($this->getCollection() as $assinproducts):  ?>
                                            <?php $products=Mage::getModel('catalog/product')->load($assinproducts->getProductId()); ?>
                                            <tr class="wk_row_view ">
                                                <td class="wk_check_first_td">
                                                    <span>
                                                        <input type="checkbox" value="<?php echo $assinproducts->getMpassignproductId(); ?>" class="mpcheckbox" name="product_mass_delete[]">
                                                    </span>
                                                </td>
                                                <td class="wk_first_td">
                                                    <span class="label name" title="<?php echo $products->getName(); ?>">
                                                        <?php 
                                                            $productname=strlen($products->getName())>7?substr($products->getName(),0,7)."..":$products->getName();
                                                            echo $products->getName();
                                                        ?>
                                                    </span>
                                                </td>
                                                <td>
                                                    <span class="label price">
                                                        <?php echo Mage::helper('core')->currency($assinproducts->getPrice(), true, false);?>
                                                    </span> 
                                                </td>

                                                <td>
                                                    <span class="label sku">
                                                        <?php echo $assinproducts->getsku() ?>
                                                    </span> 
                                                </td>

                                                <td>
                                                    <span class="label replacement">
                                                        <?php echo $assinproducts->getdeliverytime() ?>
                                                    </span> 
                                                </td>

                                                <td>
                                                    <span class="label delivery">
                                                        <?php echo $assinproducts->getreplacement() ?>
                                                    </span> 
                                                </td>


                                                <td>
                                                    <span class="label pro_status">
                                                        <?php if($assinproducts['flag']==1): ?>
                                                            <?php echo Mage::helper('mpassignproduct')->__('Approved')?>
                                                        <?php else: ?>
                                                            <?php echo Mage::helper('mpassignproduct')->__('Un-Approved')?>
                                                        <?php endif; ?>
                                                    </span> 


    </td>


<td>
    <span class="label qty" id="valueqty_<?php echo $assinproducts->getId(); ?>">
        <?php echo intval($assinproducts['qty']); ?>
    </span>

    <input type = "text" id = "qty_<?php echo $assinproducts->getId(); ?>" onkeydown="validateNumbers(event)" 
    name="stock" value="<?php echo intval($assinproducts['qty']); ?>" style="display:none;"/>

    <span class="label wk_action" id="edit_link_<?php echo $assinproducts->getId(); ?>">
        <img onclick="showField('<?php echo $assinproducts->getId(); ?>'); return false;" 
        src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>

    <p id="updatedqty_<?php echo $assinproducts->getId(); ?>" style = "display:none;color:red;">Updated</p><br/>

    <button id="update_button_<?php echo $assinproducts->getId(); ?>" class="button wk_mp_btn1" 
    onclick="updateField('<?php echo $assinproducts->getId(); ?>',<?php echo intval($assinproducts['qty']); ?>); return false;" style="display:none" >
        <span>
            <span style="font-size:12px;"><?php echo $helper->__('Update') ?></span>
        </span>
    </button>

    <button id="reset_button_<?php echo $assinproducts->getId(); ?>" type="reset" class="cancel" 
    onclick="hideReset('<?php echo $assinproducts->getId(); ?>'); return false;" style="display:none"></button> 
</td>



                                                <td>
                                                    <span class="label">
                                                        <?php 
                                                            if($assinproducts['product_condition']=='new')
                                                                echo Mage::helper('mpassignproduct')->__('New');
                                                            else
                                                                echo Mage::helper('mpassignproduct')->__('Used');
                                                        ?>
                                                    </span> 
                                                </td>
                                                <td>
                                                    <span class="label wk_action">
                                                        <img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $assinproducts->getMpassignproductId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
                                                        <img data-type="<?php echo $assinproducts->getMpassignproductId(); ?>" src="<?php echo $this->getSkinUrl('marketplace/images/icon-trash.png'); ?>" alt="<?php echo $helper->__('Delete')?>" title="<?php echo $helper->__('Delete')?>" class="mp_delete"/>
                                                    </span> 
                                                </td>                       
                                            </tr>               
                                        <?php endforeach; ?>                            
                                    </tbody>

                                </table>
                            </form>
                        <?php endif; ?>
                    </div>
                </div>
                <?php echo $this->getPagerHtml(); ?>
            </div>
        </div>
        <div class="buttons-set">
            <p class="back-link">
                <a href="javascript:;" onclick="javascript: window.history.back();" class="left">&laquo; <?php echo Mage::helper('marketplace')->__('Back') ?></a>
            </p>
        </div>
    </div>
<?php }else{
    echo "<h2 class='wk_new_msg'>".$helper->__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>";
}?>

<!-- to remove console js errors -->


<script language="JavaScript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js">
    function validateNumbers(e)
    {
        if (jQuery.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
            // Allow: Ctrl+A, Command+A
            (e.keyCode == 65 && ( e.ctrlKey === true || e.metaKey === true ) ) || 
            // Allow: home, end, left, right, down, up
            (e.keyCode >= 35 && e.keyCode <= 40)) {
                // let it happen, don't do anything
                return;
        }

        // Ensure that it is a number and stop the keypress
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    }

    var $wk_jq = jQuery.noConflict();

    (function($wk_jq){
            $wk_jq( "#special_from_date" ).datepicker({dateFormat: "yy-mm-dd"});
            $wk_jq( "#special_to_date" ).datepicker({dateFormat: "yy-mm-dd"});
            $wk_jq('#mpselecctall').click(function(event) {
            if(this.checked) {
                $wk_jq('.mpcheckbox').each(function() {
                    this.checked = true;      
                });
            }else{
                $wk_jq('.mpcheckbox').each(function() {
                    this.checked = false;           
                });         
            }
        });

        $wk_jq('body').delegate('.mp_edit','click',function(){
            var id=$wk_jq(this).attr("data-type");  
                    var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>');
                    if(dicision==true){         
                            var $type_id=$wk_jq(this).attr('data-type');                
                            window.location = "<?php echo $this->getUrl('mpassignproduct/index/edit/') ?>".concat("id/",id);    
                    }
        });

        $wk_jq('.mp_delete').click(function(){
                    var id=$wk_jq(this).attr("data-type");
                    var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>');
                    if(dicisionapp==true)
                            window.location = "<?php echo $this->getUrl('mpassignproduct/index/delete/') ?>".concat("id/",id);
            });

            $wk_jq('#mass_delete_butn').click(function(e){
                    var flag =0;
                    $wk_jq('.mpcheckbox').each(function(){
                            if (this.checked == true){
                                    flag =1;
                            }
                    });
                    if (flag == 0){
                            alert("<?php echo $helper->__(' No Checkbox is checked') ?>");
                            return false;
                    }
                    else{
                            var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>');
                            if(dicisionapp==true){
                                    $wk_jq('#form-customer-product-delete').submit();
                            }else{
                                    return false;
                            }
                    }
            });
    })($wk_jq);


    function hideReset(product_id)
    {
        var qtyId='#qty_'+ product_id;
        var editLink="#edit_link_"+ product_id;
        var updateButton="#update_button_"+ product_id;
        var resetButton="#reset_button_"+ product_id;

        $wk_jq(qtyId).hide();
        $wk_jq(editLink).show();
        $wk_jq(updateButton).hide();
        $wk_jq(resetButton).hide();
    }

    function showField(product_id)
    {
        var qtyId           = '#qty_'+ product_id;
        var editLink        = "#edit_link_"+ product_id;
        var updateButton    = "#update_button_"+ product_id;
        var resetButton     = "#reset_button_"+ product_id;

        $wk_jq(qtyId).show();
        $wk_jq(editLink).hide();
        $wk_jq(updateButton).show();
        $wk_jq(updateButton).prop('disabled', false);//just in case
        $wk_jq(resetButton).show();

        return false;
    }



    function updateField(product_id,assignqty)
    {

    //  alert("Hello! I am an alert box!!");
        var qtyId           = '#qty_'+ product_id;
        var valueId         = '#valueqty_'+ product_id;
        var updatedqty      = '#updatedqty_'+ product_id;
        var editLink        = "#edit_link_"+ product_id;
        var updateButton    = "#update_button_"+ product_id;
        var resetButton     = "#reset_button"+ product_id;
        var url             = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>';

        $wk_jq(qtyId).toggle();
        $wk_jq(editLink).hide();
        $wk_jq(updateButton).show();
        $wk_jq(resetButton).show();

        $qty = $wk_jq(qtyId).val();
        jQuery(valueId).html($qty);
        hideReset(product_id);

        var tmpQty = assignqty+parseInt($qty) ;

        new Ajax.Request(url, {
            method: 'post',
            parameters: {id: product_id, qty: tmpQty},
            onComplete: function (transport) {
            //  alert(tmpQty);
                jQuery(priceId).val($price);                
        jQuery(updatedqty).show().delay(2000).fadeOut();
                $updateButton.prop('disabled', false);
            }
        });
    }






</script>

<style>
.social-icons {
      display:none !important; 
    }
</style>

5 个答案:

答案 0 :(得分:3)

您的错误消息清楚地表明您的jQuery变量未定义。只需更改此

var $wk_jq = jQuery.noConflict();

var $wk_jq = $.noConflict();

答案 1 :(得分:2)

  默认情况下,

使用。因为它使用jquery,   建议坚持使用这个默认的jquery包。

默认jquery从目录js/lib/jquery/jquery-1.10.2.min.js加载。如果进一步检查,还可以看到另一个用于避免jquery冲突的jquery文件(/js/lib/jquery/noconflict.js)。这是该js文件的内容。

// Avoid PrototypeJS conflicts, assign jQuery to $j instead of $
var $j = jQuery.noConflict();

看看评论。它说,你应该使用$j而不是$。这意味着为了避免冲突,您需要确保三件事。

1)不要使用新的jquery包,坚持使用默认包。你不打扰这一步。 Magento会为你加载它的jquery。所以请不要再添加jquery。

2)确保在默认的jquery库之后加载noconflict.js。这也是默认Magento管理。

3)现在添加放大镜库js文件(如果有的话)(可选步骤。仅当放大镜技术依赖于任何jquery包时才需要)。

4)使用您使用放大镜js库的自定义js文件。在此文件中,您应该在任何地方使用$,而不是使用$j。这样Magento就不会发生任何jquery冲突。

答案 2 :(得分:2)

可能你没有在页面上加载jQuery。不要在页面上包含jQuery,而应该通过布局xml来完成。您甚至可以通过将其添加到app / design / frontend / package / theme / layout中的page.xml来为前端的每个页面执行此操作。一旦确定在页面上加载了jQuery,就可以选择使用noconflict,或者只使用工作jQuery替换'$'。请确保你是一致的,我在你的代码中注意到了这一点:

function updateField(product_id,assignqty)
{

//  alert("Hello! I am an alert box!!");
    var qtyId           = '#qty_'+ product_id;
    var valueId         = '#valueqty_'+ product_id;
    var updatedqty      = '#updatedqty_'+ product_id;
    var editLink        = "#edit_link_"+ product_id;
    var updateButton    = "#update_button_"+ product_id;
    var resetButton     = "#reset_button"+ product_id;
    var url             = '<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>';

    $wk_jq(qtyId).toggle();
    $wk_jq(editLink).hide();
    $wk_jq(updateButton).show();
    $wk_jq(resetButton).show();

    $qty = $wk_jq(qtyId).val();
    jQuery(valueId).html($qty);
    hideReset(product_id);

    var tmpQty = assignqty+parseInt($qty) ;

    new Ajax.Request(url, {
        method: 'post',
        parameters: {id: product_id, qty: tmpQty},
        onComplete: function (transport) {
        //  alert(tmpQty);
            jQuery(priceId).val($price);                
    jQuery(updatedqty).show().delay(2000).fadeOut();
            $updateButton.prop('disabled', false);
        }
    });
}

您正在将noconflict与原型正在使用的普通$变量混合。例如$ qty,$ price和updatebutton。如果你在这里尝试使用php变量,你必须将它们包装在一个php标签中并将它们反射出去。

答案 3 :(得分:1)

您遇到的错误是因为您没有给出正确的jQuery库路径,这就是为什么您的页面没有获得jQuery,因此它显示错误jQuery is not defined$ is not defined

答案 4 :(得分:1)

正如我所见,jQuery.js就在carrousal.js文件的下方。请将jQuery放在页面顶部,然后使用no.Conflict希望这会对你有所帮助。

Thnaks