Popup Window Problem AJAX

M

Mark Dodwell

When I try to use Ajax in a window openened by 'window.open('<url>');'
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:
------------------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Image Browser</title>
<%= javascript_include_tag '/admin/javascripts/prototype.js' %>
</head>
<body>
Search: <input type="text" id="search" name="search" />

<script type="text/javascript">
//<![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>
 
J

James Britt

Mark said:
When I try to use Ajax in a window openened by 'window.open('<url>');'
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 Britt

http://beginningruby.com - Beginning Ruby: The Online Book
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
 
R

ruby talk

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

<script type="text/javascript">
//<![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
 
M

Mark Dodwell

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
 
R

ruby talk

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top