Skip to content

Instantly share code, notes, and snippets.

@tilsammans
Created December 20, 2015 14:58
Show Gist options
  • Save tilsammans/8968cfcfaac936e985c9 to your computer and use it in GitHub Desktop.
Save tilsammans/8968cfcfaac936e985c9 to your computer and use it in GitHub Desktop.
var PostcodeCheck = React.createClass({
// all existing code again omitted
handleSubmit: function(e) {
e.preventDefault();
if (!this.state.postcode || !this.state.housenumber) {
this.setState({result: 'Postcode en huisnummer zijn verplichte velden.'});
return;
}
$.ajax({
dataType: 'json',
url: '/postcodecheck/' + this.state.postcode + '/' + this.state.housenumber + '/' + this.state.housenumberAddition,
success: function(data) {
if (data.available) {
this.setState({result: 'Uw adres is beschikbaar in BLITTS!'});
} else {
this.setState({result: 'Uw adres is helaas nog niet beschikbaar in BLITTS voor het aanvragen van een vergunning, maar u kunt wel controleren of u vergunningsvrij kunt bouwen.'});
}
}.bind(this),
error: function(xhr, status, err) {
console.error(status, err.toString());
}.bind(this)
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment