读取ajax的两个部分得到响应

时间:2015-04-29 11:45:37

标签: javascript ajax web-services

ajax响应忽略了响应的秒括号。

({"ename":"fairleyc1099@gmail.com","owner":"fairleyc1099@gmail.com","ecalculator":"false","epencil":"false","etype":"ONLINE","edate":"2015-04-22","eleangth":"2 hours","epen":"true","eruller":"true},
 {"ename":"maths","owner":"fairleyc1099@gmail.com","ecalculator":"true","epencil":"true","etype":"WRITEN","edate":"2015-04-16","eleangth":"3 hours","epen":"false","eruller":"true"})

获取响应的代码如下:

function splituplist(items){
    var temp = ""
alert(items.owner + " , , " +  items.ename +" , , " + items.edate +" , , " + items.eleangth +" , , " + items.epencil +" , , " + items.epen +" , , " + items.eruller +" , , " + items.ecalculator +" , , " + items.etype)  
temp = items.ename
document.getElementById("emttl2").value = temp;
temp = items.edate
document.getElementById("clalander2").value = temp;
temp = items.eleangth
document.getElementById("emlngth2").value = temp;

if(items.epencil == "true"){document.getElementById("ck1").innerHTML = "yes"}
else{document.getElementById("ck1").innerHTML = "no"}
if(items.eruller == "true"){document.getElementById("ck2").innerHTML = "yes"}
else{document.getElementById("ck2").innerHTML = "no"}
if(items.epen == "true"){document.getElementById("ck3").innerHTML = "yes"}
else{document.getElementById("ck3").innerHTML = "no"}
if(items.ecalculator == "true"){document.getElementById("ck4").innerHTML = "yes"}
else{document.getElementById("ck4").innerHTML = "no"}

document.getElementById("ck5").innerHTML = items.etype; 
}

function getList(items){

  var count = 0;

    for(var prop in items) {
        if(items.hasOwnProperty(prop))
            ++count;
    }

 splituplist(items);


$( "span" ).show();
}

function getexam(listID) {
    $.ajax({
        type: 'GET',    
        url: "http://localhost:8080/cust?owner=fairleyc1099@gmail.com&ename=english",  
        //url: "http://b00236085examservise.appspot.com/cust",
        async: true,
        jsonpCallback: 'getList',   
        contentType: "application/json", 
        dataType: 'jsonp',    

    });

0 个答案:

没有答案