Reputation: 73
I am getting js error as follows from my magento project.MY project url is check my project. I think it is a error with protype js.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";
}
</script>
please help me to solve this error.any help will be appreciable
Upvotes: 2
Views: 1815
Reputation: 11
Use Chrome Debugger Console and enable "Pause on exceptions" in the Sources panel. Chrome will directly show you the line in which the exception occours. If not, reload the page once or twice (thats necessary if the script is inline somewhere in a template and you use this debugger in Opera or some other Webkit based browsers, whereas in Chrome it works at once most of the time even for inline scripts).
I see that you try to use jQuery before including jQuery 1.8. Make sure you dont use jQuery before your inclusion of the jQuery lib.
The exception is thrown in minified jQuery 1.8 lib. It is unclear what exactly causes the jQuery 1.8 lib to throw an exception, i propose you include the uncompressed version so you can see where exactly the exception occurs. Ive also seen compressed versions of jQuery throwing exceptions while the uncompressed version doesnt in Magento. Using the uncompressed version could magically "solve" your problem, but the compressed version not working mostly hints to some kind of conflict between jQuery or prototype scripts.
Make sure you dont use an extension also including the jQuery script. Multiple jQuery versions in one page can cause conflicts, which can be resolved by noconflict too..
From my experience it works best if you include jquery once for all uses in the head.phtml and add jQuery.noconflict() after that. Then include all magento prototype scripts at once via layout xml and then add any other jQuery script and make sure you always encapsulate every jQuery script like written below.
Make sure every jQuery script using $ as a shortcut is encapsulated like this:
jQuery(function($) {
//your code using jQuery in $ notation
$(document).ready(function() {
//code that needs to wait for complete load of DOM
});
});
My first answer on stackoverflow, hope i could help.
Upvotes: 1