Skip to content

Instantly share code, notes, and snippets.

@juanpasolano
Created March 21, 2014 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpasolano/9698151 to your computer and use it in GitHub Desktop.
Save juanpasolano/9698151 to your computer and use it in GitHub Desktop.
Send data from local sails to remote
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script>
(function(){
function create(data){
$.ajax({
url:'http://192.157.58.90:1337/news',
type:'POST',
data: data,
success: function(data){
console.log('response from server');
console.log(data);
}
})
}
$.ajax({
url: 'http://localhost:1337/news',
type: 'GET',
success: function(data){
$.each(data, function(k, v){
delete v.id;
delete v.createdAt;
delete v.updatedAt;
create(v);
})
}
})
})()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment