[英]load php page page output into html div using jquery ajax
I want to render output of php page into html div.That means in php page has lot of jquery stuff.suppose i used current jquery ajax to load a php page.It missed to load jquery document ready stuff. 我想将php页面的输出呈现为html div。这意味着在php页面中有很多jquery stuff.suppose我使用当前的jquery ajax来加载一个php页面。它错过了加载jquery文件准备好的东西。
How can i do that? 我怎样才能做到这一点?
If you want to put the output of a php page to an html page using jquery and ajax. 如果你想使用jquery和ajax将php页面的输出放到html页面。 You may do this.
你可以这样做。
$(document).ready(function(){
$("#div1").load("demo_test.php");
});
div1 is the div which is to be updated with the php content. div1是要用php内容更新的div。 This link may help you.
这个链接可以帮到你。
http://www.w3schools.com/jquery/jquery_ajax_intro.asp http://www.w3schools.com/jquery/jquery_ajax_intro.asp
Here's is the short example. 这是一个简短的例子。 jQuery API Doc
jQuery API Doc
html HTML
<div id="content"></div>
<input type="button" id="btnLoad" value="Load" />
jquery jQuery的
$("#btnLoad").click(function(){
$.ajax({
type: 'POST',
url: 'page1.php',
success: function(data){
if(data != null) $("#content").text(data)
}
});
});
page1.php page1.php中
<?php
echo "This is the sample data to be printed for request from AJAX";
?>
you can use ajax observe
method 你可以使用ajax
observe
方法
cakephp ajax helper cakephp ajax帮手
<?php echo $form->create( 'Post' ); ?>
<?php $titles = array( 1 => 'Tom', 2 => 'Dick', 3 => 'Harry' ); ?>
<?php echo $form->input( 'title', array( 'options' => $titles ) ) ?>
<label for="something">This checkbox will be send (and it will trigger Ajax reqest) </label>
<input id="something" type="checkbox" name='data[Post][something]' value='1' />
</form>
<?php
echo $ajax->observeForm( 'PostAddForm',
array(
'url' => array( 'action' => 'edit' ),
'complete' => 'alert(request.responseText)'
)
); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.