Answer the question
In order to leave comments, you need to log in
[php] How to insert url from php code into ajax request?
I have this ajax request code
<script type="text/javascript">
$(document).ready(function(){
$('#buttonget').click(function(){
$.ajax({
url: 'demo.php',
success: function(data) {
$('.results').html(data);
}
});
})
});
</script>
<button id="buttonget">Получить результат</button>
<div class="results">Ждем ответа</div>
$demoUrl = "demo.php?parm=1&parm=2&parm3"
<script type="text/javascript">
$(document).ready(function(){
$('#buttonget').click(function(){
$.ajax({
url: <?php echo $demoUrl ?>,
success: function(data) {
$('.results').html(data);
}
});
})
});
</script>
<button id="buttonget">Получить результат</button>
<div class="results">Ждем ответа</div>
Answer the question
In order to leave comments, you need to log in
<script type="text/javascript">
$(document).ready(function(){
$('#buttonget').click(function(){
$.ajax({
url: <?php echo str_replace("</script>", "<\\/script>", json_encode($demoUrl)) ?>,
success: function(data) {
$('.results').html(data);
}
});
})
});
</script>
<button id="buttonget">Получить результат</button>
<div class="results">Ждем ответа</div>
</script>
it to be safe.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question