Reputation: 2845
I am loading ajax response to div but now i want to load it to middle iframe i tried the following but it never work! could you guys tell me what i am doing wrong ? Thanks
<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
$.ajaxSetup({ cache: false });
setInterval(function() {
//$('#divToRefresh').load('./doit.php');
$("#iframe").attr('blank.php','./doit.php'); //change url
}, 20000);
});
// ]]></script>
<iframe name="top" src="blank.php" id="top" scrolling="no" noresize frameborder="0" marginwidth="0" marginheight="0" width="100%" height="79"></iframe>
<iframe NAME="middle" src="blank.php" id="middle" noresize frameborder="0" marginwidth="0" marginheight="0" width="100%" height="238" scrolling="auto"></iframe>
<iframe NAME="foot" src="blank.php" id="foot" scrolling="no" noresize frameborder="0" marginwidth="0" marginheight="0" width="100%" height="200"></iframe>
<div id="divToRefresh">Loading ...</div>
Upvotes: 1
Views: 3324
Reputation: 33624
You ajax call is wrong or incomplete. If you want to fetch data using ajax; you should read the jQuery.ajax() documentation. But first, this and this or this.
Also read the .attr() documentation. The first parameter should be the attribute name and the second should be the value.
But; it looks like you want to redirect the page in that iframe
.
If that's the case, your selector should be #middle
:
$("#middle").attr("src", "./doit.php");
You can also do it via a link (without jQuery or javascript) like this:
<a href="./doit.php" target="middle">Do It!</a>
Upvotes: 0
Reputation: 854
The attr is used to replace an attribute, you are not stating which attribute to replace you are stating the value of that attribute
it should be something like:
$("#middle").attr('src','./doit.php'); //change url
However this is not ajax... it is plain simple iframe technique in other words the $.ajaxSetup({ cache: false }); is not used in this case.
Upvotes: 1