【发布时间】:2011-04-06 22:42:04
【问题描述】:
编辑:
我的脚本由一个按钮调用:$("#btnLogout").click(function() { the ajax here
我想知道这是否有问题:
$.ajax({
contentType: "application/json; charset=utf-8",
data: {"fname":"123456"},
dataType: "json",
type: "POST",
//url: "PersonService.asmx/AddPerson"
url: "http://mark:123456@interfaces.local/users/145198/users/update"
});
它接缝不工作,我没有收到任何错误,所以我可以看到有什么问题。
我想用来自data的值更改我的数据库中的一条记录
谢谢
好吧,
我通过arma's 帮助找到了答案。
type: "PUT", 命令用于修改某些内容。
type: "POST", 命令用于创建/添加内容。
var mydata = {"fname":"bobworth"};
$.ajax({
type: "PUT",
processData : false,
data: JSON.stringify(mydata),
dataType: "json",
url: "http://www.xxx.com/users/",
contentType: "application/json; charset=utf-8",
username: "mark",
password: "123456",
success: function(t){ alert(t); },
error: function(jqXHR, textStatus, error){
alert("jqXHR:"+jqXHR.status+" txtStatus:"+textStatus+" Error:"+error); }
});
谢谢大家。
【问题讨论】:
-
你在使用Firebug吗?