Web services I';我正在对Lists.asmx和I';我没有得到任何回报

Web services I';我正在对Lists.asmx和I';我没有得到任何回报,web-services,jquery,sharepoint,wss-3.0,Web Services,Jquery,Sharepoint,Wss 3.0,我有一个sharepoint列表,我正在使用Lists.asmx使用ajax提供信息,但是服务器没有返回任何信息。。。。我做错了什么 这是我的代码: var Currentlocurl; $(document).ready(function() { $(".vincLista").bind("click", function(){ L_Menu_BaseUrl = "empaquetamiento" if (window.location.port !=

我有一个sharepoint列表,我正在使用Lists.asmx使用ajax提供信息,但是服务器没有返回任何信息。。。。我做错了什么

这是我的代码:

var Currentlocurl;

$(document).ready(function() {
    $(".vincLista").bind("click", function(){
        L_Menu_BaseUrl = "empaquetamiento"
        if (window.location.port != null || window.location.port != '') {
            Currentlocurl = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + L_Menu_BaseUrl;
           }
        else {
            Currentlocurl = window.location.protocol + "//" + window.location.hostname + L_Menu_BaseUrl;
          }

         var listurl = Currentlocurl + "/_vti_bin/lists.asmx";
         var listname = "Empaquetamiento";
         var query = "<Where>" + 
            "<And>" +
                "<Eq>" + 
                    "<FieldRef Name='Plan' />" + 
                    "<Value Type='Choice'>" + $(this).data("plan") + "</Value>" + 
                "</Eq>" + 
                "<Eq>" + 
                    "<FieldRef Name='Operacion' />" + 
                    "<Value Type='Choice'>" + $(this).data("operacion") + "</Value>" + 
                "</Eq>" + 
            "</And>" +
            "</Where>";

         var soap = "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
            <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
            <soapenv:Body> \
            <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
            <listName>" + listname + "</listName><query><Query>" + query + "</Query></query> \
            <viewFields><ViewFields>\
                <FieldRef Name='id' />\
                <FieldRef Name='Nombre' />\
                <FieldRef Name='Descripcion' />\
                <FieldRef Name='Codigo SAP' />\
                <FieldRef Name='Proforma' />\
                <FieldRef Name='Imagen grande' />\
                <FieldRef Name='Imagen pequeña' />\
            </ViewFields></viewFields> \
            </GetListItems> \
            </soapenv:Body></soapenv:Envelope>";

      $.ajax({
           url: listurl,
           beforeSend: function (xhr) {
                       xhr.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetListItems");
                   },
          type: "POST",
          dataType: "xml",
          data: soap,
          complete: function (xData, status) {
               $(xData.responseXML).find("z\\:row").each(function () {
                    var infoDiv = $('<div/>', {class: "pieza", text: $(this).attr("ows_Nombre") + $(this).attr("ows_Descripcion")});
                    $("#info").append(infoDiv);
                  });
               },
          contentType: "text/xml; charset=utf-8"
        });
    });
});
var-Currentlocurl;
$(文档).ready(函数(){
$(“.vincLista”).bind(“单击”,函数(){
L_Menu\u BaseUrl=“empaquetamiento”
if(window.location.port!=null | | window.location.port!=''){
Currentlocurl=window.location.protocol+“/”+window.location.hostname+”:“+window.location.port+L_菜单\u基本URL;
}
否则{
Currentlocurl=window.location.protocol+“/”+window.location.hostname+L_菜单\u BaseUrl;
}
var listurl=Currentlocurl+“/\u vti\u bin/lists.asmx”;
var listname=“Empaquetamiento”;
var query=”“+
"" +
"" + 
"" + 
“+$(此).data(“计划”)+”+
"" + 
"" + 
"" + 
“+$(此).data(“操作”)+”
"" + 
"" +
"";
var soap=”\
\
\
\
“+listname+”“+query+”\
\
\
\
\
\
\
\
\
\
\
";
$.ajax({
url:listurl,
发送前:函数(xhr){
setRequestHeader(“SOAPAction”http://schemas.microsoft.com/sharepoint/soap/GetListItems");
},
类型:“POST”,
数据类型:“xml”,
数据:soap,
完成:功能(扩展数据、状态){
$(扩展数据.responseXML).find(“z\\:行”).each(函数(){
var infoDiv=$('',{class:“pieza”,text:$(this.attr(“ows_Nombre”)+$(this.attr(“ows_description”)});
$(“#info”)。追加(infoDiv);
});
},
contentType:“text/xml;charset=utf-8”
});
});
});
这是我的html:

<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7",lang=''><![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8",lang=''><![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9",lang=''><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta charset="utf-8" />
    <title>Empaquetamiento</title />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="" />
    <meta name="author" content="" />

    <!-- Libraries-->
    <!-- Javascript extra-->
    <!--[if lt IE 9]>
    <script src="/empaquetamiento/JS/html5shiv.js"></script>
    <script src="/empaquetamiento/JS/html5shiv-printshiv.js"></script><![endif]-->
    <!-- Support for IE6-8 of HTML5 elements-->

    <script type="text/javascript" src="javascript/modernizr.min.js"></script>

    <!-- Css Styles-->
    <link rel="stylesheet" href="stylesheets/empaquetamiento.css"/>

</head>
<body>
    <button class="vincLista" data-plan="Plan1" data-operacion="inicio" >Traer info</button>
    <button class="vincLista" data-plan="Plan1" data-operacion="diseño" >Traer info</button>
    <button class="vincLista" data-plan="Plan2" data-operacion="inicio" >Traer info</button>
    <button class="vincLista" data-plan="Plan2" data-operacion="diseño" >Traer info</button>
    <div id="info" ></div>

    <button class="vincPieza" data-id="1" >Traer info</button>
    <div id="pieza" ></div>

    <script type="text/javascript" src="javascript/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="javascript/empaquetamiento.js"></script>
</body>
</html>

恩帕奎塔米恩托
追踪者信息
追踪者信息
追踪者信息
追踪者信息
追踪者信息

正在调用ajax方法,但我从未从服务器上得到答案,甚至没有错误。

您是否尝试过使用FireBug或Chrome的内置开发工具调试服务器调用?您可以使用这些工具查看服务器调用和服务器响应。

我发现了问题所在,首先我在列表列中使用了尖锐的元音,如“operación”和“descripción”,这些词给我带来了一些麻烦,而且我的菜单基url也错了

以下是经过一些重构后更正的代码:

var Currentlocurl;

$(document).ready(function() {

    L_Menu_BaseUrl = "/empaquetamiento"
    if (window.location.port != null || window.location.port != '') {
        Currentlocurl = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + L_Menu_BaseUrl;
    }
    else {
        Currentlocurl = window.location.protocol + "//" + window.location.hostname + L_Menu_BaseUrl;
    }

    var listurl = Currentlocurl + "/_vti_bin/lists.asmx";
    var listname = "Empaquetamiento";

    $(".vincLista").bind("click", function(){
        var query = "<Where>" + 
            "<And>" +
                "<Eq>" + 
                    "<FieldRef Name='Plan' />" + 
                    "<Value Type='Choice'>" + $(this).data("plan") + "</Value>" + 
                "</Eq>" +
                "<Eq>" + 
                    "<FieldRef Name='Operacion' />" + 
                    "<Value Type='Choice'>" + $(this).data("operacion") + "</Value>" + 
                "</Eq>" +
            "</And>" + 
            "</Where>";

         var viewFields = "<ViewFields>\
                <FieldRef Name='Title' />\
                <FieldRef Name='Nombre' />\
                <FieldRef Name='Imagen' />\
            </ViewFields>";

        var soap = "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
            <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
            <soapenv:Body> \
            <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
            <listName>" + listname + "</listName><query><Query>" + query + "</Query></query> \
            <viewFields>" + viewFields + "</viewFields> \
            </GetListItems> \
            </soapenv:Body></soapenv:Envelope>";

        $.ajax({
            url: listurl,
            beforeSend: function (xhr) {
                xhr.setRequestHeader("SOAPAction","http://schemas.microsoft.com/sharepoint/soap/GetListItems");
            },
            type: "POST",
            dataType: "xml",
            data: soap,
            complete: function (xData, status) {
                $(xData.responseXML).find("z\\:row, row").each(function () {
                    var infoDiv = $('<div/>', {class: "pieza", text: $(this).attr("ows_Nombre") + " - " + $(this).attr("ows_Imagen")});
                    $("#info").find("#pieza").delete;
                    $("#info").append(infoDiv);
                });
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert(thrownError);
            },
            contentType: "text/xml; charset=utf-8"
        });
    });
});
var-Currentlocurl;
$(文档).ready(函数(){
L_Menu_BaseUrl=“/empaquetamiento”
if(window.location.port!=null | | window.location.port!=''){
Currentlocurl=window.location.protocol+“/”+window.location.hostname+”:“+window.location.port+L_菜单\u基本URL;
}
否则{
Currentlocurl=window.location.protocol+“/”+window.location.hostname+L_菜单\u BaseUrl;
}
var listurl=Currentlocurl+“/\u vti\u bin/lists.asmx”;
var listname=“Empaquetamiento”;
$(“.vincLista”).bind(“单击”,函数(){
var query=”“+
"" +
"" + 
"" + 
“+$(此).data(“计划”)+”+
"" +
"" + 
"" + 
“+$(此).data(“操作”)+”
"" +
"" + 
"";
变量视域=”\
\
\
\
";
var soap=”\
\
\
\
“+listname+”“+query+”\
“+视野+”\
\
";
$.ajax({
url:listurl,
发送前:函数(xhr){
setRequestHeader(“SOAPAction”http://schemas.microsoft.com/sharepoint/soap/GetListItems");
},
类型:“POST”,
数据类型:“xml”,
数据:soap,
完成:功能(扩展数据、状态){
$(扩展数据.responseXML).find(“z\\:行,行”).each(函数(){
var infoDiv=$('',{class:“pieza”,text:$(this.attr)(“ows_Nombre”)+“-”+$(this.attr)(“ows_Imagen”)});
$(“#info”)。查找(“#pieza”)。删除;
$(“#info”)。追加(infoDiv);
});
},
错误:函数(xhr、ajaxOptions、thrownError){
警报(thrownError);
},
contentType:“text/xml;charset=utf-8”
});
});
});

Hi,是的,谢谢。我已经发现了一些问题,首先,L_Menu_BaseUrl=“empaquetamiento”应该是L_Menu_BaseUrl=“/empaquetamiento”才能正常工作。