jquery
  • dom
  • dom-manipulation
  • 2012-04-14 4 views 1 likes 
    1

    새 DB 레코드를 삽입하고 사용자에게 보여줘야하는 웹 페이지가 있습니다.jQuery - 추가 된 행 표시

    내가 원하는 것은 사람을 추가 할 때 s (he)가 추가 된 행을보아야한다는 것입니다.

    function AddData(par){ 
    
        var artistName = $("input[name='"+par+"']").attr('id') + '-'+$("input[name='"+par+"']").val(); 
    
        $.post('/json/management/AddDataAjax2', 
        { 
         "artistName": artistName 
        }, 
        function(response){ 
         console.log(response); 
         if(response =='ok'){ 
          alert("Başarıyla eklendi"); 
         } 
         else{ 
          alert("Sanatçı bulunamadı, yönlendiriliyorsunuz"); 
          window.location.replace("http://www.sinemalar.com/management/artistAddEditRemove/"); 
         } 
    }); 
    } 
    

    example of showing added records

    탭은 모든 div의 위치 : 나는 아래의 코드를 가지고있다. 각 탭에 ID를 부여하고 레코드를 삽입 한 후 div 새로 고침을 추가했습니다. 그러나로드 된 원본 페이지를 렌더링합니다. 해결책은 무엇입니까?

    답변

    1

    그냥 이런 식으로 뭔가를 당신이 데이터를 표시 할 사업부를 만들 :

    <div id="added"></div> 
    
    유용한 예를 찾을 수 있습니다 : 편집

    그리고이에 jQuery를 편집 :

    function(response){ 
        console.log(response); 
        if(response =='ok'){ 
         $("#added").append(artistName . "<br>"); 
         alert("Başarıyla eklendi"); 
        } 
    
    +0

    코드에 문제가 있습니까? –

    0

    페이지를 새로 고치는 대신 append()를 사용하여 새 항목을 목록에 추가 할 수 있습니까?

    test.html를 >>

    <script src="jquery.min.js" type="text/javascript"></script> 
    <script type="text/javascript">                          
    
    $(document).ready(function() { 
        $("input[type='button']").click(function() { 
         value = $("input[type='text']").val(); 
         $('ui').append("<li>"+value+"</li>"); 
        }); 
        }); 
    
    </script> 
    <ui id='list'> 
        <li>item1</li> 
        <li>item2</li> 
    
    </ui> 
    
    <input type='text'/><input type='button' value='Add'/> 
    
    관련 문제