Skip to content

Instantly share code, notes, and snippets.

@james-gardner
Last active August 29, 2015 13:57
Show Gist options
  • Save james-gardner/9511985 to your computer and use it in GitHub Desktop.
Save james-gardner/9511985 to your computer and use it in GitHub Desktop.
function (number, country) {
var req, valid = $.Deferred();
req = $.ajax({
type : 'GET',
url : '/api/v3/validation-url',
dataType : 'json',
data : {
phonenumber : number,
countryid : country
}
});
req.then(function (data) {
if(data.valid) {
valid.resolve(data);
} else {
valid.reject(data);
}
});
return valid;
};
function (number, country) {
var dfd = $.Deferred();
$.getJSON('/api/v3/validation-url', {
phonenumber : number,
countryid : country
}).then(function (data) {
if(data.valid) {
dfd.resolve(data);
} else {
dfd.reject(data);
}
}, dfd.reject.apply(arguments)
);
return dfd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment