2013-08-28 26 views
0

以下函數用於使用jQuery從Web服務獲取信息。此代碼工作正常即10,但它即8和9,即jQuery Web服務調用,I.E 9,8

功能GetDemo(用戶)返回錯誤「不傳輸」 {

var webMethod = "http://---------/Service.asmx/Demo"; 
var parameters = '{"UserName":"'+ User + '"}'; 

$.ajax({ 
    type: "POST", 
    url: webMethod, 
    data: parameters, 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    success: function(msg) { 

    if(typeof msg.d[0] !== "undefined") { 
    $("#Designation").html(msg.d[0]['Designation']); 
    } 
    else 
    { 
    // $("[title='Name']").val("");  
    }   
    }, 
    error: function (xhr, ajaxOptions, thrownError) { 
     alert(xhr.status); 
     alert(xhr.responseText); 
     alert(thrownError); 
    } }); 

}

任何建議?

+0

http://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error –

+0

@Delphian jQuery.support.cors = TRUE; 找到答案,你只需要把上面的代碼行放在ajax之前,呼叫I.E 7,&I.E 8. – codery2k

+0

希望它解決你的問題 –

回答

0

jQuery.support.cors = true;

只需在調用服務之前添加這些行。