0

我需要这个函数作为 jQuery。

有一部分 jQuery,但我发现编写代码很困难!

function showUser(str) {
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("drop_em").innerHTML = xmlhttp.responseText;
            $('#scrollbar3').tinyscrollbar();
        }

    }
    xmlhttp.open("GET", "list_playlist_popup.php?qq=" + str, true);
    xmlhttp.send();
}
4

4 回答 4

3

你试过什么?你被困在哪里了?(因为这是jQuery中最基本的AJAX调用形式)

$.get(
  "list_playlist_popup.php",
  { qq: str },
  function success(data) {
    $('#drop_em').html(data);
    $('#scrollbar3').tinyscrollbar();
  });
于 2013-09-22T16:40:37.887 回答
0

使用 jQuery Ajax:

 $.ajax({
                url:'list_playlist_popup.php',
                type:'POST',
                data:{
                  variable : value
                },
                success:function(data){

                    alert('success');
                }
  })
于 2013-09-22T16:40:41.073 回答
0
function showUser(str) {
    $.get('list_playlist_popup.php',{qq:str},function(response) {
        $('#drop_em').html(response);
        $('#scrollbar').tinyscrollbar();
    });
};

这是你的 jQuery 等价物。

于 2013-09-22T16:40:53.423 回答
0

只需将其复制粘贴到现有功能上即可。

function showUser( str ) {

    $.ajax({
        url: 'list_playlist_popup.php',
        data: {
            'qq': str
        }
    }).done(function( data ) {

        $('#drop_em').html(data);
        $('#scrollbar3').tinyscrollbar();
    });

}
于 2013-09-22T16:46:03.113 回答