2013-10-18 2 views
-3

jQuery 페이지의 jQuery 메서드 중 아무 것도 동일한 방식으로 작동하지 않을 수있다.jQuery에서이 Ajax 코드와 동일한 것은 무엇입니까?

function enableAjaxTask(removeLink){ 

    var xmlhttp = false; 


    if(window.XMLHttpRequest){ 
     xmlhttp = new XMLHttpRequest(); 
    }else{ 
     xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); 
    } 

    xmlhttp.onreadystatechange = function(){ 
     if(xmlhttp.readyState === 4 && xmlhttp.status === 200){ 
      document.getElementById('foo').innerHTML = xmlhttp.responseText; 
     } 
    } 


    xmlhttp.open('GET', 'foo.php?id=22', true); 
    xmlhttp.send(null); 

} 
+1

http://api.jquery.com/jQuery.ajax/ –

+1

을'jQuery를 ('# foo는')처럼해야한다. load ('foo.php? id = 22')' – steveukx

+1

무엇이 당신의 생각인가요? 한번 해보십시오. 문제가 생기면 도움을 요청하고 노력을 게시하십시오. –

답변

1

가이

$.ajax({ 
    type: 'GET', //GET/POST 
    url: 'foo.php',//URL to send request 
    data: 'id=12', //query parameters here, you can direct pass url: 'foo.php?id=12' 
    success: function(responseText){ 
      //called if the request succeeds. also check complete ,done, error 
     $('#foo').html(responseText); 
    } 
}); 
+0

꽤 둥글다. –

1
$("#foo").load('foo.php?id=22'); 

http://api.jquery.com/load/

+0

꽤 좋았지 만, 이것은 아마도 OP를위한 운동으로 남겨져 있었을 것입니다. –

관련 문제