This is my react code and I want to print the JSON format code in table format using react JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Initial Data Via AJAX</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/jsx">
var ImageCollect = React.createClass({
getInitialState: function() {
return {
phpData: []
};
},
componentDidMount: function() {
$.get(this.props.source, function(result) {
var collection = result;//when i print this by using console.log the collection is getting the JSON code
if (this.isMounted()) {
this.setState({
phpData : collection
});
}
}.bind(this));
},
render:function()
{
DBdata = this.state.phpData || [];
return (
<div>
<table>
<th>name</th>
<th>email</th>
{DBdata.map(function(d){
return(
<tr>
<td>{d.name}</td>
<td><d.email</td>
</tr>
)}
)}
</table>
</div>
)}
});
React.render(
<ImageCollect source="http://localhost/PHP-React-Demo/index.php" />,
document.getElementById('example')
);
</script>
</body>
</html>
And following is my JSON format code i getting from index.php file the output is only name and email
{"data":[{"id":"1","name":"param","email":"param@nadsoft.com","phone":"9890245130","marks":"65"},{"id":"2","name":"andy","email":"andy@gmail.com","phone":"9665815566","marks":"78"},{"id":"3","name":"asdf","email":"dfgfd@fgdfgd.com","phone":"2132323232","marks":"23"},{"id":"34","name":"rteret","email":"fdg@dfsdf","phone":"21312323232","marks":"23"},{"id":"4236","name":"kjhkj","email":"opiuio","phone":"9890245130","marks":"7"},{"id":"4237","name":"","email":"","phone":"","marks":"0"}]}
May i change the JSON code or the react ? where should i change and this react code is returning only name and email not the data.