문제

I have set up a pylons server to accept requests of the form "/searcher?q=blahblah". This returns some nice json of the form:

[{"name":"onefish","type":"one"},{"name":"twofish",type:"two"}]

I get this using the javascript:

function search() {
   var query = $('#search_box').val();
   $.getJSON('/searcher',
      {
         q: query
      },
      function(data) {
         $.each(data,function(index,element) {
            $(body).append($('<div>',{text: element.name}));
         }
      }
   );
}

This successfully queries the server when called and it is called (the server gives response code 200). However, the code does not add anything to the body. The same nothing happens when I replace $(body).append(...); with something like $('#some_id').html(...);. Is there something wrong with my query, my parsing, or my output?

도움이 되었습니까?

해결책

I solved this myself. body needs to be in quotes...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top