0

I am getting js error as follows from my magento project.MY project url is check my project. i tried js noconflict but no use.

Error:

Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value) is not a function www.bigzaar.com/:1 Uncaught ReferenceError: jQuery is not defined www.bigzaar.com/:93 Uncaught ReferenceError: jQuery is not defined www.bigzaar.com/:151 Uncaught ReferenceError: jQuery is not defined www.bigzaar.com/:157 Uncaught ReferenceError: jQuery is not defined www.bigzaar.com/:420 Uncaught ReferenceError: jQuery is not defined jquery.mobile.customized.min.js:10 Uncaught ReferenceError: jQuery is not defined camera.js:2238 Uncaught ReferenceError: jQuery is not defined www.bigzaar.com/:607 Uncaught ReferenceError: jQuery is not defined www.bigzaar.com/:704 Uncaught ReferenceError: jQuery is not defined www.bigzaar.com/:863 Uncaught ReferenceError: jQuery is not defined

my js file:

/********Javascript for FREE TEXT SEARCH ************/
var Quicksearch = Class.create();
var idSearchInput = '';
Quicksearch.prototype = {
    initialize: function(searchUrl,resultNotice,idSearchInput){
        this.idSearchInput = idSearchInput;
        this.searchUrl = searchUrl;     
        this.onSuccess = this.onSuccess.bindAsEventListener(this);        
        this.onFailure = this.onFailure.bindAsEventListener(this);              
        this.currentSearch = '';    
        this.resultNotice = resultNotice;
    },
    search: function(){ 
        var searchBox = $(this.idSearchInput);

        if(searchBox.value=='')
        {
            return;
        }

        if ((this.currentSearch!="") &&(searchBox.value == this.currentSearch)) {
            return;
        }
        this.currentSearch = searchBox.value;

        searchBox.className =  'loading-result input-text';
        var keyword = searchBox.value;


        url = this.searchUrl+"keyword/" + escape(keyword);

        new Ajax.Request(url, {
              method: 'get',         
              onSuccess: this.onSuccess,

              onFailure: this.onFailure 
          });    
    },
    onFailure: function(transport){
        $(this.idSearchInput).className ="input-text";
    },
    onSuccess: function(transport)
    {
        var showResults = $('showResults');
        showResults.style.display = "block";
        var listResults = $('listResults');
        listResults.style.display = "block";
        var searchBox = $(this.idSearchInput);
        if (transport && transport.responseText) {
            try{
                response = eval('(' + transport.responseText + ')');
            }
            catch (e) {
                response = {};
            }

            if (response.html != "") {
                this.currentSearch = searchBox.value;
                listResults.update(response.html);
                var searchResultNotice = this.resultNotice;
                var strNotice = searchResultNotice.replace("{{keyword}}",this.currentSearch);
                this.updateResultLabel(strNotice);
                searchBox.className = 'search-complete input-text';
            }
            else
            {
                listResults.update(response.html);
                this.updateResultLabel('No results for "<span class="keyword">'+this.currentSearch+'</span>"');
                searchBox.className ="search-complete input-text";
            }           
        }       
    },
    updateResultLabel: function(message)
    {
        $("resultLabel").update(message);
    }
}

my js calling function

<script type="text/javascript">
var quicksearch = new Quicksearch(
    '<?php echo $this->getUrl('freetextsearch/search/quicksearch') ?>',
    '<?php echo $resultNotice ?>',
    'input_search'
);
var numberChar = <?php echo Mage::getStoreConfig('freetextsearch/quick_search_setting/number_character')?>;
Event.observe('input_search', 'keyup', function(event){
    var searchBox = $('input_search');
    if(searchBox.value.length >= numberChar){
        quicksearch.search();
    }   
});
function closeDropdown() {
    var showResults = $('showResults');
    showResults.style.display = "none";
}

please help me to solve this error.any help will be appreciable

1

First I would turn off js merging in System -> Configuration -> Advanced -> Developer -> JavaScript Settings -> Merge Javascript Files = No. Then you can see the order your files are included and actually do some debugging.

Secondly I would make sure that between your prototype includes and your jquery include you have a jquery noconflict defined jQuery.noConflict();

Simply create a small .js file with that content and include it just before including jquery.

Now checking your merged file I can see that the error is that you have included the /********Javascript for FREE TEXT SEARCH ************/ prior to including the jquery library.

Make sure you change the order so that your script is loaded AFTER jQuery has been included.

If you check your merged .js file, you can see that your FREE TEXT SEARCH .js is added in line 11852, but you don't include jquery until line 11929, so of course you will receive 'jquery is not defined' errors when you try and execute your javascript.

  • do you know how to add extension js(/********Javascript for FREE TEXT SEARCH ************/) after including jquery – Siby Thomas May 12 '15 at 9:14
  • Well, as I do not know how you included your javascript it's hard to tell. Any good devloper would use layout/local.xml to add or remove custom javascript files in the <reference name="head"> with something like so: <action method="addItem"><type>skin_js</type><name>js/jquery-ui/jquery-ui.min.js</name></action> where skin_js means the file is located in 'skin/frontend/themebase/yourtheme/' folder. – tecjam May 12 '15 at 9:30
  • Hi when i do System -> Configuration -> Advanced -> Developer -> JavaScript Settings -> Merge Javascript Files = No. it is fixed – Siby Thomas May 12 '15 at 9:37
  • Just remember that in this case the issue itself is not fixed because you can not merge your js file without the error occuring. Of course if you want to leave it that way (but take into account more http calls to js files) it is entirely up to you. =) – tecjam May 12 '15 at 9:40
  • i am a fresher to magento i have basic knowledge in php how to be a magento expert. what i have to study first. any useful links – Siby Thomas May 12 '15 at 9:50
0

Sorry for a comment as an answer; I don't yet have commenting privileges.

Does your code work if you replace the jQuery $( with jQuery(?

Another option that solves this problem for me is to wrap your template file's javascript with:

jQuery(document).ready( function($){

to pass $ into the ready callback. Doing this keeps the Prototype/jQuery issue from arising within the callback function.

  • where i have to put this code – Siby Thomas May 11 '15 at 10:20
0

In Magento 1.9.2, check that /js -> /varien -> configurable.js and product.js have a semicolon ; at the very end of the file. If not, add one to each and then try to merge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.