ajax 跨域 iis7,IIS7.5下的RESTful不能跨域PUT和POST

用Postman测试成功,但是在自己写的jQuery代码中测试失败

可以Get,但是不能PUT和POST

IIS7.5中web.config已经做了如下设置

jQuery代码

$.ajax({

url: 'http://xxx.xxx.xxx.xxx:nnnn/api/apps/791',

type: 'PUT',

data: '{"Name": "Tom"}',

dataType: 'json',

contentType: 'application/json',

crossDomain: true,

beforeSend: function( xhr ) {

xhr.setRequestHeader('X-Requested-With', 'jQuery');

},

success: function( response ) {

console.log('ok');

}

});

浏览器 Chrome 53

General

Request URL:http://XXX.XXX.XXX.XXX:10088/api/apps/791

Request Method:OPTIONS

Status Code:405 Method Not Allowed

Remote Address:XXX.XXX.XXX.XXX:10088

Response Headers

Access-Control-Allow-Headers:X-Requested-With

Access-Control-Allow-Methods:GET, PUT, POST, DELETE, OPTIONS

Access-Control-Allow-Origin:*

Allow:PUT,GET

Cache-Control:no-cache

Content-Length:66

Content-Type:application/json; charset=utf-8

Date:Tue, 13 Sep 2016 02:00:41 GMT

Expires:-1

Pragma:no-cache

Server:Microsoft-IIS/7.5

X-AspNet-Version:4.0.30319

X-Powered-By:ASP.NET

Request Headers

Accept:*/*

Accept-Encoding:gzip, deflate, sdch

Accept-Language:zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4,zh-TW;q=0.2

Access-Control-Request-Headers:content-type, x-requested-with

Access-Control-Request-Method:POST

Connection:keep-alive

Host:XXX.XXX.XXX.XXX:10088

Origin:http://XXX.XXX.XXX.YYY:7788

Referer:http://XXX.XXX.XXX.YYY:7788/jqdebug.html

User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值