Skip to content

Instantly share code, notes, and snippets.

@lastday154
Last active June 22, 2017 02:25
Show Gist options
  • Save lastday154/ddc4f1423f83c70ae58e8924e5e586f7 to your computer and use it in GitHub Desktop.
Save lastday154/ddc4f1423f83c70ae58e8924e5e586f7 to your computer and use it in GitHub Desktop.
Synchronous request
// Synchronous request to get 3 unique messages from zalora.sg
var messages = [];
while(messages.length < 3) {
$.ajax({
url: 'https://www.zalora.sg/ajax/catalog/justforyou/?feedName=recentlyviewed&brandName=&size=20&category=&userId=10214339066013667&engine=datajet',
async: false
})
.done(function(msg){
if(messages.indexOf(msg) == -1) {
messages.push(msg);
}
})
.fail(function() {
alert( "can not get message from zalora");
});
}
console.log(messages);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment