2011-03-06 5 views
0

ajax get 호출에서 id로 스크립트 노드를 선택하려고합니다.get 호출에서 jquery select 스크립트 노드

<script id="jqgrid_js" type="text/javascript"> 
... 
</script> 

가져 오기 전화 : 같은 선택 문이 노드를 반환하지 않는 이유 노드가 확실히 "결과"VAR에 포함되는 반면

  $.get(url, function(results){ 
       console.debug(results); //the jqgrid_js is included in the result 
       console.debug($('#jqgrid_js')); //this returns the node from the actual page 
       console.debug($('#jqgrid_js', results)); // in the result I can not select it 
       var jqgrid_js = $('#jqgrid_js', results); 
       //do the update 
       $('#jqgrid_js').html(jqgrid_js); 
      }, "html"); 

나는, 궁금하네요.

+0

는'context'는 HTML 문자열이 될 수 없습니다 : 확인 http://api.jquery.com/jQuery/ –

+0

, 그리고 내가 무엇을해야합니까 변화? –

답변

0

주변이 터닝 대신 find를 사용해보십시오 :

var jqgrid_js = $(results).find('#jqgrid_js'); 
+0

은 아무 것도 변경하지 않습니다. 그 동안 나는 이것을 발견했다 : http://stackoverflow.com/questions/4430707/trying-to-select-script-tags-from-a-jquery-ajax-get-response .. –