I’m trying to reload only specific div
$("#captcha").html('<?php echo 'abc';?>'); // just as test - works well
Because div content is much larger, I tried:
$("#captcha").html('<?php include 'myFile.php';?>'); // doesn't work
How can I call the code from a .php file into a div ?
use
$('div').load('phpfile.php')$.loadis used to load data from the server via an html file or a server-side script like php.Just to have an overview of what you can do with
$.loadyou can also load page fragments by including a selector after the page you want to retrieve. This way only the contents of the selected element will be loaded into your container. You can also pass in data and execute functions after the request has complete(callbacks).$.htmlis different because its only used to get or set the contents of an existing element.You can however use it with ajax methods like
$.post,$.get,$.ajaxto update the contentsof an existing element.
Read up jQuery’s documentation on the $.load and $.html methods
if you want to have an in-depth understanding on how these method works.