[英]Having a PHP function run on jQuery callback
$('#target').html(????????)
or .ajax()
? $('#target').html(????????)
或.ajax()
?
Need this to load a php page in the <div>
with id target. 需要它在<div>
以id为目标加载一个php页面。 How do I call that php page? 我怎么称呼那个PHP页面?
This is my problem it wasn't my setup it was trying to include the javascript variable obj.info: 这是我的问题,不是我的设置,它试图包含javascript变量obj.info:
function(obj){jQuery.ajax({'url':'/controller/\'+obj.info+\'','cache':false,'success':function(html){jQuery('#target').html(html)}})}
Whenever I try to work the variable obj.info it the function fails. 每当我尝试使用变量obj.info时,函数都会失败。
$('#target').load('url/to/php/script.php');
$.ajax({
'url/to/php/script.php',
data: { 'varName': yourJsVariable },
success: function(response) {
// your php script returns HTML content
//
$('#element').html(response);
}
});
Check the page on .ajax() for more info: http://api.jquery.com/jQuery.ajax/ 检查.ajax()上的页面以获取更多信息: http : //api.jquery.com/jQuery.ajax/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.