In my project there is a process.php which is process the data according to the GET input.
For instance:
If scandir.php?page=5 , it will return an encoded json object which is an multidimensional array.
Now I am modifying the ajax part, how to call the php , assign the value to php and have the results returned and display?
Below is the example code I found from tutorial site, it doesn’t seems pass any value to the php file ?
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="prev"></div>
<div id="curr"></div>
<div id="next"></div>
<script>
$(document).ready(function(){
var url = 'scandir.php?' + 'page=5';
$.getJSON(url , null,
function(data) {
$.each(data.items, function(i,item){
console.log(item);
});
});
});
</script>
</body>
</html>
The json object sample created by the PHP file
{"prev":["","demo\/medium\/Web081112_P001_medium.jpg"],"curr":["demo\/medium\/Web081112_P002_medium.jpg","demo\/medium\/Web081112_P003_medium.jpg"],"next":["demo\/medium\/Web081112_P004_medium.jpg","demo\/medium\/Web081112_P005_medium.jpg"]}
I think you should do it like this: