玉祥平台客服-15087858732

标题: AJAX技术 [打印本页]

作者: Adam丶鱼    时间: 2020-7-23 17:44
标题: AJAX技术
1.post请求
$.ajax({
    type: 'post',
    url: '/GetProdects.ashx',
    async: true,
   //data: {id:'2'}  请求参数
    success: function (result) {
        var json = JSON.parse(result)['Head'];
        prodectVue.prodects = json;
    },
    error: function () {
        setContainer('ERROR!');
    }
});

2.get请求
$.ajax({
    type: 'get',
    url: '/DeleteProdect.ashx?id='+2,
    async: true,
    success: function (result) {
        //alert(123)
        if (result == '1')
        {
            alert('删除成功');
            showProdect();
        }
        else
            alert('系统繁忙');
    },
    error: function () {
        setContainer('ERROR!');
    }
});
3.ajax跨站请求
$.ajax({
    type: 'get',
    url: 'http://域名/DeleteProdect.ashx?id='+id,
    async: true,
    success: function (result) {
        //alert(123)
        if (result == '1')
        {
            alert('删除成功');
            showProdect();
        }
        else
            alert('系统繁忙');
    },
    error: function () {
        setContainer('ERROR!');
    }
});

在处理函数中需要加入:context.Response.AppendHeader("Access-Control-Allow-Origin", "*");


作者: Adam丶鱼    时间: 2020-7-23 17:45

作者: 张兴康    时间: 2020-7-24 14:22

作者: fteair    时间: 2020-7-24 17:29

作者: 张兴康    时间: 2020-7-26 14:36

作者: fteair    时间: 2020-7-26 17:39





欢迎光临 玉祥平台客服-15087858732 (http://bbs.delit.cn/) Powered by Discuz! X3.2