Skip to content

Instantly share code, notes, and snippets.

@cacheflow
Created October 7, 2015 21:36
Show Gist options
  • Save cacheflow/4cd3757818baab71965e to your computer and use it in GitHub Desktop.
Save cacheflow/4cd3757818baab71965e to your computer and use it in GitHub Desktop.
var SearchRetailers = React.createClass({
getInitialState: function() {
return {
data: {},
};
},
sendForm:function(formData) {
formData.preventDefault();
var query = React.findDOMNode(this.refs.search).value.trim();
$.ajax({
url: this.props.url,
dataType: 'json',
cache: false,
type: 'get',
success: function(data) {
this.setState({data: data});
console.log(data)
}.bind(this),
error: function(xhr, status, error) {
console.log(this.props.url, status, error.toString());
}.bind(this)
});
},
render: function() {
return (
<form className="inputForm" onSubmit={this.sendForm}>
<input type="text" ref="search" />
<input type="submit" value="post" />
</form>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment