2011-07-07 74 views
0

我不知道這是錯誤還是我的錯,但我不明白。AJAX發佈數據示例問題

如果您是AJAX專家,那麼您可以在沒有ENYO知識的情況下回答此問題。

in數據ENYO的例子,你可以看到AJAXGET和AJAXPOST方法。

  1. 無論這種方法的工作在模擬器,但不是在克羅姆(那是跨瀏覽習題?)
  2. 而且在AJAXPOST前。數據

    var postdata ='fname = enda & lname = mcgrath';

已發佈未在結果中顯示發送後按鈕。

/* Copyright 2009-2011 Hewlett-Packard Development Company, L.P. All rights reserved. */ 
enyo.kind({ 
    name: "network.AJAXPost", 
    kind: HeaderView, 
    components: [ 
     {name: "postButton", kind: "Button", caption: "Send Post", onclick: "sendPost"}, 
     {name: "postResponse", kind: "HtmlContent", allowHtml: "true"}, 
     {name: "post", kind: "WebService", 
      url: "http://www.snee.com/xml/crud/posttest.cgi", 
      method: "POST", 
      onSuccess: "onSuccess", 
      onFailure: "onFailure"} 
    ], 
    sendPost: function() { 
     var postdata='fname=enda&lname=mcgrath'; 
     this.$.post.call({ 
     handleAs: "text", 
     postBody: postdata, 
     contentType: 'application/x-www-form-urlencoded' 
     }); 
    }, 
    onSuccess: function(inSender, inResponse) { 
     this.$.postResponse.setContent(inResponse); 
     console.log("success response = " + inResponse); 
    }, 
    onFailure: function(inSender, inResponse) { 
     this.$.postResponse.setContent(inResponse); 
     console.log("failure response = " + inResponse); 
    }, 
}); 
在此代碼

,如果我替換此行

url: "http://www.snee.com/xml/crud/gettest.cgi?fname=enda&lname=mcgrath", 

它的工作原理。 你可以得到這個爲什麼不工作postdata? 爲什麼瀏覽器不顯示發佈的數據?

回答