2013-09-22 2 views
0

이 함수는 jQuery로 필요합니다.이 함수를 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(); 
} 
+0

내가 실수가 아니라면'$ .ajax'를'success' 속성과 함께 사용하여'onreadystatechange'를 실행할 수 있습니다. –

+0

이 함수에서 무엇이 필요합니까, 아약스 요청을 수행해야합니까 ??? –

+0

@ jawawe하지만 jquery에서! 난 단지 jquery를 사용하여 작동 완전한 함수를 구축 할 수 없다 – user2765449

답변

3

무엇을 시도 했습니까? 어디서 붙어 있니?

$.get(
    "list_playlist_popup.php", 
    { qq: str }, 
    function success(data) { 
    $('#drop_em').html(data); 
    $('#scrollbar3').tinyscrollbar(); 
    }); 
0

사용 jQuery를 아약스 (이 jQuery를에 AJAX 호출의 가장 기본적인 형태이기 때문에) :

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

        alert('success'); 
       } 
    }) 
0
function showUser(str) { 
    $.get('list_playlist_popup.php',{qq:str},function(response) { 
     $('#drop_em').html(response); 
     $('#scrollbar').tinyscrollbar(); 
    }); 
}; 

이것은 당신의 jQuery와 동일합니다.

+0

함수 showUser (str)에 넣어야합니까 ??? – user2765449

+0

예. 그것은 그것이 속한 곳입니다. – DevlshOne

0

기존 기능 위에 붙여 넣기 만하면됩니다.

function showUser(str) { 

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

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

} 
관련 문제