English 中文(简体)
ajax发布后用php页面更新iframe
原标题:Update iframe with php page after ajax post
$("form#update").submit(function() {
    var formData = $("form#update").serialize();
        $.ajax({
            type: "POST",
            url: "graph.php",
            data: formData + "&criteria=" + critSelected,
            success: function(data){
                $( div.graph ).fadeOut(function(){$( div.graph ).html(data).fadeIn();});
            }
        });
    return false;
});

我有一个响应表单提交的脚本。graph.php将是一个完整的html页面,我希望在不重新加载整个页面的情况下显示它。有没有什么方法可以让我把表单所在页面上iframe的源代码改为graph.php(比如说它在div图中)?我试过放置$(iframe).attr(src,url);在成功函数中没有任何作用。感谢您的帮助。谢谢

最佳回答

You can post directly to iframe using form.target= frame name Than the result will be loaded in iframe automaticly

例如

<form method="POST" target="framename">...</form>
问题回答

如果我读对了你所做的,它不起作用的原因是因为你试图使用url作为变量,它是ajax选项中属性的名称。如果您将代码更改为$(“iframe”).attr(“src”,“graph.php”)它应该工作,或者设置url变量。

概念涂鸦:http://jsfiddle.net/XcnMt/





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签