Created
June 29, 2016 14:50
-
-
Save aisrael/efa0162db88a0b737c1250a984ac2b79 to your computer and use it in GitHub Desktop.
React + $.ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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