ajax将响应结果显示到iframe,如何每隔20秒加载$ .ajax(jquery)对iframe的响应?(How to load $.ajax (jquery) response to ifram...

如何在我的页面中加载此jquery获取响应中间iframe? php脚本从mysql db加载一些数据? 在这种情况下,我没有传递任何数据到PHP所以我需要提出获取或发布请求? 我的代码在alert中显示jquery响应,但是没有将它加载到iframe中!

setInterval(function() {

$.ajax(

{

type: 'GET',

url: './getDataFromMySQLdb.php',

//data: $("#myform").serialize(),

data: {

title: 'test',

// wrapper: 'testing'

},

success: function (good)

{

//handle success

alert(good);

$("#middle").attr('src',+good); //change url

},

failure: function (bad)

{

//handle any errors

alert(bad)

}

});

}, 20000);

How i can load this jquery get response to middle iframe in my page? The php script loads some data from mysql db? in this case i am not passing any data to php so do i need to make get or post request ? my code display the jquery response in alert but doesn't load it into iframe!

setInterval(function() {

$.ajax(

{

type: 'GET',

url: './getDataFromMySQLdb.php',

//data: $("#myform").serialize(),

data: {

title: 'test',

// wrapper: 'testing'

},

success: function (good)

{

//handle success

alert(good);

$("#middle").attr('src',+good); //change url

},

failure: function (bad)

{

//handle any errors

alert(bad)

}

});

}, 20000);

原文:https://stackoverflow.com/questions/14865658

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值