I am trying to learn the Jquery AJAX function but am struggling to work out how to pass PHP variables into my main document.
This is what I currently have:
<script>
var refreshId = setInterval(function() {
$.ajax({
url: "test.php",
dataType: "json", //the return type data is jsonn
success: function(data){ // <--- (data) is in json format
$('#testdiv').html(data.test1);
$('#testdiv').append(html(data.test2));
//parse the json data
}
});
}, 1000);
</script>
You should use
jsonorxmlformat and parse it, and get the variable.on
test.php