2017-05-21 1 views
-1

Inspect elemet을 사용하는 동안 Ajax를 사용하여 데이터를 게시합니다. 다른 모든 필드의 게시물 데이터를 볼 수 있지만 텍스트 영역 필드가 비어 있으므로 데이터가 저장되지 않습니다. 데이터 베이스.TextArea가 데이터를 전송하지 않습니다. Submit

function addblog() { 

     save_method = 'add'; 

     url = "<?php echo site_url('index.php/blog/post_new_blog')?>"; 

     $.ajax({ 
      url: url, 
      type: "POST", 
      data: $('#addblog').serialize(), 
      dataType: "json", 
      success: function (data) { 
        alert('Saved'); 
      }, 
      error: function (jqXHR, textStatus, errorThrown) { 
        alert('Error adding/update data'); 
     } 
    }); 
} 

HTML :

<div id="editor-one" class="editor-wrapper"></div> 
    <textarea id="descr" class="text" name="desc" style="display:none;"></textarea> 

PHP :

public function post_new_blog() 
{ 
    $data = array(
     'blog_title' => $this->input->post('title', true), 
     'blog_content' => $this->input->post('desc', true), 
     'blog_tags' => $this->input->post('tags', true), 
    ); 

    $insert = $this->main_model->save_new_posts($data); 

    echo json_encode(array("status" => TRUE)); 
} 
+0

열기/닫기 텍스트 영역 사이에 공백이 없어야합니다. – manian

+0

'style = "가시성 : 숨김; 위치 : 절대;"로 변경하십시오. 그것은 작동해야합니다. 비슷한 질문에 대한보기 (여기에) (http://stackoverflow.com/questions/8318428/submit-form-fields-inside-displaynone-element) – jagad89

+2

'display : none'이있는 필드는 전송되지 않습니다 – RST

답변

0

다음과 같이 데이터를 전송됩니다

data: $('#addblog').serialize(), 

을한다
<textarea id="descr" class="text" name="desc" style="display:none;"></textarea> 

id가있는 html 요소 addblog?

그런데 왜 텍스트 영역에 표시를 설정하지 않는지 이해하지 못했습니까?

관련 문제