1
Hello, I’m calling a page .php
with the method load
, his problem is that when I give include
into something that should stay this way include './dir/arquivo.php';
after the load
loads the page include
is obliged to stay this way to work ../dir/arquivo.php
, in addition to some elements not working.
But when I only use the include
direct, no JS to call, works perfectly, I would like a way to make the JS(or even PHP) execute include 'arquivo.php'
(or any form that does not remain bugado
) when the button is pressed.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(){
$("#div").load('arquivo.php');
});
});
</script>
<input type="button" id="button">
<div id="div"></div>
Example of code that does not work:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script type="text/javascript">
$(function()
{
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
var upload = $('form').ajaxForm(
{
beforeSend: function()
{
},
uploadProgress: function(event, position, total, percentComplete)
{
//aumenta barra de progresso
},
complete: function(xhr)
{
}
});
});
</script>
<form enctype="multipart/form-data" method="post" id="formSendTorrent" name="formSendTorrent">
<input type="file" multiple name="inputfileSendTorrent[]" id="inputfileSendTorrent">
<input type="submit" name="submitSendTorrent" value="Enviar">
</form>
<?php
if(isset($_POST['submitSendTorrent']))
{
header('Location: index.php');
}
?>
What content do you have in this file that you want to give include ? is something too extensive or not enough? Because you could create a file. PHP that returns a JSON and makes a request in AJAX and assembles the content in your HTML file
– Henrique Felix
In this file is JS, HTML and PHP, an entire page that I call inside a DIV. I changed the question.
– Lucas Caresia
Theoretically this right. "In addition to some elements not working" it arrives to load the file then ? or load but without all functions ?
– Henrique Felix
For example, I have a code where when you upload a file JS takes the percentage and then it should continue to run PHP, this code works perfectly, but when I use the
load
it does not run the PHP below.– Lucas Caresia
Could you describe a little more about the problem?
– Klaider
@Matheus The last code I put in the question, when I use
include 'arquivo.php'
it loads JS(loading upload bar), HTML and PHP(leading to the home page), but when I load this samearquivo.php
with the method.load
of JS it can only run JS and HTML, PHP ends up not running.– Lucas Caresia
@Lucascarezia, are you running this HTML+JS on a Webserver? If not, it may be the reason you don’t run php on . load...
– Pedro Antônio
I went through the same problem and solved including the file that should be included in php direct in the index. So all the elements loaded by . load() will work. I found the answer https://stackoverflow.com/questions/30092127/jquery-load-and-php-include
– Pedro Augusto