Comment lire des données XML renvoyé par webservice en JQuery

ASMX:

    public class ItemRecord
    {
        public string model { get;set; }
        public string verzia { get;set; }
        public string typ { get;set; }
        public string motor { get;set; }
    }

    [WebMethod]
    public ItemRecord GetRecord(int id)
    {
        ItemRecord record = new ItemRecord();

        using (SqlConnection sConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["bazarovkyConnectionString"].ToString()))
        {
            sConnection.Open();


            SqlCommand sCommand = sConnection.CreateCommand();
            sCommand.CommandText = "select id_model, motor from data_motorizacia where id=@id";
            sCommand.Parameters.AddWithValue("@id", id);

            SqlDataReader sReader = sCommand.ExecuteReader();
            if (sReader.Read())
            {
                record.model = sReader["id_model"].ToString();
                record.motor = sReader["motor"].ToString();
            }
        }

        return record;

    }

JQUERY:

id = $("#view_id", row).text();

$.ajax({
    type: "POST",
    url: "/data.asmx/GetRecord",
    data: "{'id':'" + id + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "xml",
    processData: false,
    error: function (XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest, textStatus, errorThrown); },
    success: function (xml) { ajaxFinish(xml); }
});

function ajaxFinish(xml) {
    //parse the object
    alert($(xml).find("motor").text());

}

Ce que je veux faire est de lire la valeur de moteur et id_model dans ajaxFinish. Mais elle renvoie soit l'objet (si je me réfère à XML uniquement) ou indéterminée ou vide.

Comment puis-je suivre/debug ce qui a été renvoyé de .ASMX fichier?

InformationsquelleAutor feronovak | 2011-02-28