我不知道这是错误还是我的错,但我不明白。
如果您是 AJAX 专家,那么您可以在没有 ENYO 知识的情况下回答这个问题。
在 ENYO 的 DATA 示例中,您可以看到 AJAXGET 和 AJAXPOST 方法。
- 这两种方法都适用于模拟器,但不适用于 Crome(这是跨浏览器问题吗?)
在 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 吗?为什么浏览器不显示发布的数据?