# Popup Window Problem AJAX

**URL:** <https://www.ruby-forum.com/t/popup-window-problem-ajax/102624>\
**Category:** Ruby\
**Created:** [December 15, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/popup-window-problem-ajax/102624 "2006-12-15T22:35:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [December 15, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/popup-window-problem-ajax/102624/1 "2006-12-15T22:35:33Z")

</div>

When I try to use Ajax in a window openened by ‘window.open(’’);’  
it doesn’t work. There is no exceptions raised as far as I can see  
(debugging with FireBug).

However, if I refresh the window once it has popped up it does work. Is  
there something I’m missing?

## Code in my popup window:
 Image Browser \<%= javascript\_include\_tag '/admin/javascripts/prototype.js' %\> Search: //\<![CDATA[new Form.Element.Observer( 'search', 0.5, function(element, value) { new Ajax.Updater( 'items', '/admin/browser/items?item\_type=ImageAsset', { asynchronous: true, evalScripts: true, parameters: 'search=' + escape(value) } ) }); //]]\> \</script\> \<div id="items"\>\</div\> \</body\> \</html\> ------------------------------------------------------------ \<p\>Many Thanks,\<br\> Mark\</p\>

---

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [December 15, 2006, 10:54pm UTC](https://www.ruby-forum.com/t/popup-window-problem-ajax/102624/2 "2006-12-15T22:54:27Z")

</div>

Mark D. wrote:

> When I try to use Ajax in a window openened by ‘window.open(’‘);’  
> it doesn’t work. There is no exceptions raised as far as I can see  
> (debugging with FireBug).
> 
> However, if I refresh the window once it has popped up it does work. Is  
> there something I’m missing?

You might do better to ask JavaScript questions on a JavaScript mailing  
list.

–  
James B.

[http://beginningruby.com](http://beginningruby.com) - Beginning Ruby: The Online Book  
[Ruby Code & Style](http://www.artima.com/rubycs/) - The Journal By & For Rubyists  
[http://www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff

---

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [December 16, 2006, 12:10am UTC](https://www.ruby-forum.com/t/popup-window-problem-ajax/102624/3 "2006-12-16T00:10:41Z")

</div>

Sorry I don’t have time to mock this up and test my idea. Try moving

 //\<![CDATA[new Form.Element.Observer( 'search', 0.5, function(element, value) { new Ajax.Updater( 'items', '/admin/browser/items?item\_type=ImageAsset', { asynchronous: true, evalScripts: true, parameters: 'search=' + escape(value) } ) }); //]]\> below \<div id="items"\>\</div\> Sbecker

---

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [December 16, 2006, 12:16am UTC](https://www.ruby-forum.com/t/popup-window-problem-ajax/102624/4 "2006-12-16T00:16:09Z")

</div>

Thanks, but that doesn’t help.

Is it something to do with a security issue that popup windows can’t  
make Ajax requests maybe? This is really annoying me!

Ta, Mark

---

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [December 16, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/popup-window-problem-ajax/102624/5 "2006-12-16T21:22:13Z")

</div>

If it works after you refresh the popup window then its not a security  
issue.

If you pull the ajax call out of the form observer, does it send a  
message to the server when the page loads?

Sbecker
