I'm using a framework (yii2) and i'm adding a jQuery code inside my view. Like this:
$js = '$(document).ready(function(){
$("#showmap").click(function(event){
.....
function success(position) {
...
$.ajax({
url : "../frontend/web/getContent.php",
type: "POST",
data: {success : "success", latitude : latitude, longitude : longitude},
success: function (data){
var jsonmap = JSON.parse(data);
var address = jsonmap["results"]["0"]["formatted_address"];
$("#StreetName").val(address);
}
});
}
});
});
';
$this->registerJs($js);
I have the file "getContent.php" in web directory. Where is the right place to put the file? What's the best method to do this code? Everything works great, but i don't know if this is the best way.