Can the scenario below be achieved?
Here is the ajax response I received:
HTML
<body>
<input type="text"></input>
<div id="trydiv"></div>
</body>
JS
$.ajax({
type: "POST",
url: "json.php",
data: 'val='+$('input').val(),
success: function(response){
$('#trydiv').load("try1.js");
}
});
json.php
<?php
echo json_encode($_POST['val']);
?>
try1.js
<script type="text/javascript">
$(function(){
alert(response);
});
</script>
Considering that I am passing 'response' in the success function, should there not be a way for "response" to be accessible in try1.js? Is there a method to pass response to a js/html file and then utilize it there?