Last active
July 12, 2022 10:36
-
-
Save npapratovic/4c7338c87e9df44efb79ff25f76d5848 to your computer and use it in GitHub Desktop.
On button click start function with ajaxcall to remote to fetch data and store data in another div
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a id="clickme">Click me!</a> | |
<div id="populateme"></div> | |
<script>jQuery(function ($) { | |
$(document).ready(function(){ | |
var getdest = '/session/getdest'; | |
$(document).on('click', '#clickme', function() { | |
changeDiv(); | |
}); | |
function changeDiv() { | |
$.ajax({ | |
url: getdest, | |
type: 'POST', | |
//dataType: 'json', | |
data: {'id': 1}, | |
success: function(response) { | |
//console.log(response); | |
$('#populateme').html(response); | |
}, | |
error: function(xhr){ | |
console.log("An error occured: " + xhr.status + " " + xhr.statusText); | |
} | |
}) | |
} | |
}) | |
}) | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function actionGetdest() { | |
$session = \Yii::$app->session; | |
$date_range = $session['check-in'] . ' → ' . $session['check-out']; | |
echo $date_range; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment