0

NODJS で簡単な Web サーバーを作成しました。Web ブラウザ、つまり firfox に接続すると、hello world が表示されhttp://localhost:8888/ます。しかし、enyon Web サービスの onSuccess コールバックは、inResponse からの null 文字列を表示します。静的な Web ページを作成し、enyo がローカルの hypache サーバーから正常にロードしました。nodejsから送信されたものからenyoが常にw nullを表示しないのはなぜですか??

ウェブサーバー

http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);

ボタンを押すとWebサービスを実行し、アラートボックスに結果を表示する簡単なenyoプログラムを作成しました

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(); }
});

テッド

4

1 に答える 1

0

独自の Web サービスを作成する必要がある理由はありますか? enyo.WebService の種類は既に用意されており、使用できます。

本当に独自のものが必要な場合は、次のサンプル プロジェクトでサービスがどのように実装されているかを確認することをお勧めします: https://github.com/palm/txjs-fortunecookie

于 2012-01-13T16:54:08.170 に答える