I made a simple web sevrer in NODJS. the web browser ie firfox will display hellow world, when connected to http://localhost:8888/
. But the enyon web service onSuccess callback displays a null string from the inResponse. I created a static web page and enyo loaded it in fine from my local hypache server. Why wont enyo always show w null from stuff sent from nodejs??
the web server
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
I wrote a simple enyo program that when you press the button it does a webservices and shows the results in a alert box
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(); }
});
Ted
Is there a reason you need to write your own Web Service? The enyo.WebService kind is already there for your use.
If you truly need your own, I recommend taking a look at how services are implemented in the following sample project: https://github.com/palm/txjs-fortunecookie