rest接口返回是比较灵活的,可以根据请求者的需求返回xml,json,string等格式

rest接口返回是比较灵活的,可以根据请求者的需求返回xml,json,string等格式;

设置返回格式方式:

$.ajax({
        url:'http://'+oaip+'/seeyon/rest/token/'+restup+'?loginName='+ loginName,
        type:'GET',
        headers:{Accept:"application/json; charset=utf-8"}, //直接设置http头
        //dataType:'xml',
        //'contentType': "application/json; charset=utf-8",
        data:'',
        success: function(response){
            userId=response.id;  //解析json数据

            //userId=response.getElementsByTagName("id")[1].firstChild.data; //解析xml数据
            //alert(userId);
            var ju="";

猜你喜欢

转载自my.oschina.net/u/2426537/blog/1627156