Created
October 7, 2015 21:36
-
-
Save cacheflow/4cd3757818baab71965e to your computer and use it in GitHub Desktop.
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
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