I make an ajax call with:
index.php
$.ajax({
type:'post',
url:'abc.php',
success:function(returned_data)
{
// returned_data contains HTML + javascript code
// I'd like to access the javascript variable here
// refer to abc.php's code to see what variable
// somehow access "new_variable" here
}
})
abc.php
<table id="first_table">
<tr>
.
.
.
<!-- some un-related td content -->
</tr>
</table>
<script>
new_variable = $('#first_table').dataTable();
// now I want new_variable to be available in index.php page; i.e. inside the success
// function of the ajax method
</script>
Can this be achieved? Or any alternative to achieve this?
document.write(new_variable);in your abc.phpconsole.log(new_variable)insidesuccessfunction is giving me the result. Don't know why it didn't work earlier..Thanks for your time though