While attempting to parse JSON data using AJAX, I came across an example on this site:
how to parse json data with jquery / javascript?
In the example provided, it worked flawlessly for them, but in my case, the content turned blank.
Simply trying to echo the PHP showed the JSON without any issues. Trying to figure out what could be causing the problem.
<!DOCTYPE HTML>
<html>
<head>
<link type ="text/css" rel="stylesheet" href= "css/bootstrap.css">
<link type ="text/css" rel="stylesheet" href= "css/account.css">
</head>
<body>
<p id="result">fefe</p>>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$.ajax({
type: 'GET',
url: 'get.php',
data: { get_param: 'value' },
dataType:'json',
success: function (data) {
var names = data
$('#result').html(data);
}
});
</script>
</body>
</html>
Here is what the JSON result looks like in PHP:
[{"id":"1","userid":"26","title":"654","description":"654"}]