ajax技術
阿新 • • 發佈:2017-10-02
context == access tex response function acc $.ajax vue
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", "*");
ajax技術