我下面有这段代码,我正在尝试将数据发送到服务器,但是我唯一要连接的文档是向服务器发送的示例数据,它看起来像这样org.testng.Assert.assertEquals(assert_LoginFailure.getText(),arg1);
,我在做什么吗?这里的我的代码在这里是错误的,因为我不断收到错误405和{“method”:“fruit-post”,“data”:{“red-fruits”:["Apple","Cherry","Tomato"],“green-fruits”:["Grapes","Watermelon"],“yellow-fruits”:["Lemon","Pear"],“purple-fruits”:[]}}
任何帮助,将不胜感激
Response for preflight has invalid HTTP status code 405.
答案 0 :(得分:1)
您的Ajax请求错误。在这里http://api.jquery.com/jquery.ajax/
方法必须为POST
,GET
或PUT
$.ajax({
url: "LINK",
method: "POST",
data: {
“method”:“fruit-post”,
“data”:{
“red-fruits”:["Apple","Cherry","Tomato"],
“green-fruits”:["Grapes","Watermelon"],
“yellow-fruits”:["Lemon","Pear"],
“purple-fruits”:[]
}
},
dataType: "html",
cache: false,
success: function(data) {
}
});
答案 1 :(得分:0)
ajax使用方法type:'get'
或"post"
,不需要method
在网址中提及您的方法
$.ajax({
url: "LINK",
type: "POST",
data: {
"data": fruitString
},
dataType: "html",
cache: false,
success: function(data) {
}
});