Skip to content

Instantly share code, notes, and snippets.

@garyshort
Created December 22, 2011 23:48
Show Gist options
  • Save garyshort/1512373 to your computer and use it in GitHub Desktop.
Save garyshort/1512373 to your computer and use it in GitHub Desktop.
NodeCode
var twitter_config_model = {
track: ko.observable(''),
follow: ko.observable(''),
locations: ko.observable(''),
onSave: function(formElement){
$.ajax({
url: "http://localhost:8080/trinity/configure",
type: "PUT",
data: ko.toJSON(this),
headers: {'Origin':'http://localhost'},
success: function() {
alert('worked!');
},
error: function(xhr, status, error){
alert(xhr.status);
}
});
}
};
ko.applyBindings(twitter_config_model);
var server = require('express').createServer().listen('8080');
server.post('/trinity/configure',function(req,res){
res.header("Access-Control-Allow-Origin", "htt://localhost");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.send('Hello', 200);
});
@garyshort
Copy link
Author

these are my client and server files. I've included the cors headers I think I need and it's still not working, do you see why?

@garyshort
Copy link
Author

btw, I did notice the type was wrong in the client call (was PUT should be POST). I corrected it but it still fails. :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment