Created
December 22, 2011 23:48
-
-
Save garyshort/1512373 to your computer and use it in GitHub Desktop.
NodeCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
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
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?