Skip to content

Instantly share code, notes, and snippets.

@aisrael
Created June 29, 2016 14:50
Show Gist options
  • Save aisrael/efa0162db88a0b737c1250a984ac2b79 to your computer and use it in GitHub Desktop.
Save aisrael/efa0162db88a0b737c1250a984ac2b79 to your computer and use it in GitHub Desktop.
React + $.ajax
class MyTable extends React.Component {
constructor(props) {
super(props);
$.ajax({
url: 'localhost/path',
dataType: 'json',
cache: true,
success: function (resp) {
console.log(this);
this.state = resp.data;
}.bind(this),
error: function (xhr, status, err) {
console.error(status, err.toString());
}
});
console.log(this.state);
}
render() {
console.log(this.state);
return (
<div>
<table>
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment