Answer the question
In order to leave comments, you need to log in
Pass from JS to PHP?
Hello. I have a problem.
I will try to describe in detail.
Task. It is necessary to make the simplest code editor in php. I plan to do editing in .
How I want to do it:
This code gets the address of a file.
<script type="text/javascript">
$(document).ready( function() {
$('#fileTreeDemo_1').fileTree({ root: '../../1/', script: 'connectors/jqueryFileTree.php' }, function(file) {
var m = (file);
// alert(m);
});
</script>
<?php $a = file_get_contents("путь который надо получить"); ?>
<textarea type="text" name="a1" rows="3" cols="80" > <?php echo $a;?></textarea>
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#test").click(function(event){
var postVar = "hi";
$.ajax({
url: 'index4.php',
data : 'postVar',
type : "POST",
success: function (data) {
alert (data);
},
error: function(){
alert ("No PHP script: ");
}
});
return false;
});
});
</script>
<?php
echo $_POST['postVar'];
?>
<?php
echo $_GET['m']; //это дополнительно пробую
print $_GET['m']; //это дополнительно пробую
if (isset($_POST['u_name']))
{
echo $_POST['u_name'] . '</p>';
}
else
{
echo "<script type='text/javascript'>";
echo "document.write('<textarea>' + m + '</textarea>');";
echo "</script>";
exit();
}
?>
Answer the question
In order to leave comments, you need to log in
Haven't tried that?
<form action="save">
<label>some code</label>
<textarea id="content"></textarea>
</form>
$.get('/source', {'name': 'SomeClass.php'}, function(data) {
('#content').val(data);
});
if (isset($_GET['name']) {
return file_get_contents($_GET['name']);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question