English 中文(简体)
从动态列表中获取值并将其返回为字符串
原标题:Get values from dynamic list and return them as a string

我正在着手一个项目, 用户将选择一个文档, 并将将其放入动态和可排序的列表中。 列表项目将具有特定文档 id 的值。 一旦列表排列完毕, 用户将点击创建列表, 我想使用 Ajax 和经典 ASP (在此过程中需要使用几个 queire 来抓取新字符串格式) 来抓取列表项目的纯值, 并将其放入一个阵列 。

以下是我目前的名单:

<ul class="main_doc_list">
  <li><b>Editor s Blog</b>
  <ul class="doc_list">
      <li value="111111">Doc Title</li>
   </ul>
   </li>
   <li><b>Blog Roll</b>
    <ul class="doc_list">
      <li value="222222">Doc Title</li>
      <li value="333333">Doc Title 2</li>
      <li value="444444">Doc Title 2</li>
    </ul>
    </li>
   </ul>

我目前在JQuery有这个 来引发Ajax事件

$("#create").click(function() {
    $.ajax(
            {
            type: "GET",
            url: "newslettercreate_action.asp",
            success: function(result) {
                var newsletter_string = $(result);
                $("#scratch").val(newsletter_string);
            }
        });

    }) 

只是不确定在我的 ASP 动作文件中 如何获取我所需要的值, 以开始建立新闻机字符串的功能。 任何帮助都会非常感激 。

最佳回答

正如Porco指出的,你可以在张贴前 和jQuery 自己抓住这个, 你只需要绕过每个元素, 将各种价值结合起来, 就像Porco说的:

$("#create").click(function() {
    // get some data 
    var strDocIDs = "";
    $( .main_doc_list ).find( li[value] ).each(function() {
        strDocIDs += ", " + $(this).attr( value );
    });

    if (strDocIDs != "") alert(strDocIDs.substring(2)); // substring here rips off the first comma
})

要张贴数据, 做Porco给你们看的, 你可以将 ASP 上的结果作为请求变量 :

strDocIDs = Request("strDocIDs")
问题回答

只需要传递一些数据:

$("#create").click(function() {

    // get some data
    var strDocIDs = $( .main_doc_list ).find( li ).first().attr( value );

    $.ajax(
            {
            type: "GET",
            url: "newslettercreate_action.asp",
            data: { " strDocIDs : " + strDocIDs + " }",
            success: function(result) {
                var newsletter_string = $(result);
                $("#scratch").val(newsletter_string);
            }
    });

}) 




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签