0
我在NODJS中做了一個簡單的網絡分類器。當連接到http://localhost:8888/
時,web瀏覽器即firfox將顯示出世界的和諧。但是,enyon web服務onSuccess回調會顯示來自inResponse的空字符串。我創建了一個靜態網頁,enyo通過我的本地hypache服務器加載了它。爲什麼不會enyo總是顯示w null從nodejs發送的東西??試圖使用NODEJS和enyo作爲前端創建Web服務
Web服務器
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
我寫了一個簡單enyo程序,當你按下按鈕,它做了web服務,並顯示在一個警告框
enyo.kind({
name: "MyApps.MainApp",
kind: enyo.VFlexBox,
// comment code to load in data gfrom service
components: [
{name: "getName", kind: "WebService",
onSuccess: "gotName",
onFailure: "gotNameFailure",
url: "http://localhost:8888/"
},
{kind: "PageHeader", content: "Enyo FeedReader"},
{name:"curValue", content:("Sample Text")},
{kind: "Button", caption: "Action", onclick: "btnClick"} ],
// functions go here
create: function()
{
// call the default creat then do our stuff
this.inherited(arguments);
this.$.getName.call();
},
// Show output of server,
gotName: function(inSender, inResponse) {
this.$.button.setCaption("Success");
alert(inResponse);
},
// go here if it cold not connect to server
gotNameFailure: function(inSender, inResponse) {
this.$.button.setCaption("Failure"); },
// call the server
btnClick: function() {
this.$.getName.call(); }
});
結果泰德
謝謝你的鏈接,仍然無法正常工作,但在web瀏覽器領事顯示「XMLHttpRequest無法加載http:// localhost:3000 /。原因http:// localhost:81不被Access-Control-Allow-Origin允許。」任何想法? – 2012-01-14 15:32:21