How do I get past jQuery's "$ not found error" error?

MAIN WINDOW

// some javascript //some html //here ajax-call to load all divs //all divs hidden by default //based on user choice(from select option), show selected group of divs //click any shown div to call corresponding popup 

POPUP WINDOW

 //edit contents of that div. //on close i need 1. refresh main window to load all divs 2. select the previously selected user option(from select option) 3. show corresponding divs only 4. most important is i have to give the user the main page, where they clicked the div before(not the page starting always!) 

I tried and I was left with a "$ not found error". any ideas..? offers?

this is the main window

  <script type="text/javascript" src="jquerymin.js"></script> <script type="text/javascript"> var visible_status=0; function selectFn(sno){ if(sno==1){ $('#id2').hide(); $('#id1').show(); visible_status=1; }else if(sno==2){ $('#id2').show(); $('#id1').show(); visible_status=2; } } function popitup(url) { newwindow=window.open(url+'?parent_status='+visible_status,'name'); if (window.focus) {newwindow.focus();} return false; } </script> <select name='optionw' onchange="selectFn(this.options[this.selectedIndex].value);"> <option value="">Select</option> <option value="1">Div1</option> <option value="2">All</option> </select> <div id='id1' style="display:none;">DIV1</div><!--by ajax i am loading--> <div id='id2' style="display:none;">DIV2</div><!--these divs--> <button onclick="popitup('popup.php');">popUp</button><br><!--and these--> 

popupwindow

 <script type="text/javascript" src="jquerymin.js"></script> <script type="text/javascript"> var parent_status='<? echo $_GET[parent_status];?>'; function closePopup() { window.opener.history.go(0); //alert('going to call parent selectFn('+parent_status+')'); window.opener.selectFn(parent_status); self.close(); } </script> ...Here editing a part of the main page content... <input type=button value=close_popup onclick="closePopup();"> 

If I remove comments in the closePopup function, it works as expected. Any help to make it work without a string.

0
source share
4 answers

I would suggest that you might be linking to the jQuery library incorrectly or linking to it in the wrong order. Could you provide more information about what you are asking? Do you want the code to do this, or are you just asking that a jQuery object was not found?

+2
source

get the firebug plugin for firefox. load your page .. go to firebug console .. enter $ and if it doesn't say 'function ()' you haven't included the proper jQuery library

+1
source

I am trying to understand your question; it is very unclear what you are describing. Is the code you are showing displayed from your web browser after it is downloaded (by viewing the source) or before it is evaluated on the server?

What happens if you change this line in a popup window:

var parent_status='<? echo $_GET[parent_status];?>';

:

var parent_status=1;

0
source

According to what I understood here, the code is below and check it if this works for you:

Paste this code into the main window:

 <?php if(isset($_GET['parent_status'])): ?> $(document).ready(function(){ selectFn(<?php echo $_GET['parent_status'] ?>); }) <?php endif ?> 

Below this code:

 function popitup(url) { newwindow=window.open(url+'?parent_status='+visible_status,'name'); if (window.focus) {newwindow.focus();} return false; } 

And replace the closePopup function inside the popup with this code:

 function closePopup() { var href = window.opener.location.href; if((pos = href.lastIndexOf('parent_status=')) >= 0) { var patt = new RegExp('parent_status=' + parent_status); href = href.replace(patt, 'parent_status='+parent_status); } else { href = window.opener.location.href + '?parent_status=' + parent_status } window.opener.location.href = href; self.close(); } 

Hope this helps.

0
source

All Articles