Jump to content
php.lv forumi

Izvadit Ajax kļūdu


vostro

Recommended Posts

Sveiki, gribēju uzzināt kā pareizi izvadīt kļūdu AJAX formā.

JS

   	$('#formAddComents').submit(function(){

   	var send = $(this).serialize();
   	$.ajax({
       	type: 'POST',
       	url: '/news/add',
       	data: send,
       	dataType: "json",
       	success: function(msg){
           	$('.commentsList').append("<div class='commentsImage'><div><img src='/users_images/"+msg.user_image+"' border='1' width='100' height='90' /></div></div><div class='commentsText'>"+msg.text+"</div><div class='commentsUsersData'><span style='margin-right: 5px; margin-top: 5px; margin-left: 5px; font-size: 12px;'><a href='/users/"+msg.user_id+"'>"+msg.author+"</a></span> <span style='float: right; margin-right: 5px; margin-top: 5px; font-size: 12px; color: gray; '>"+msg.date+"</span></div><br />");
                	$(":input").val('');
        	}

       	});

       	return false;
   	});

PHP

   $page_id = $this->input->post('page_id');

       	$user_id = $this->input->post('user_id');

       	$user_images = $this->input->post('user_image');
       	$author = $this->input->post('name');
       	$text = $this->input->post('textComments');
       	$date = date("d.m.y H:i:s");
       	$data = array(
           	'page_id' => $page_id ,
           	'user_id' => $user_id ,
           	'user_image' => $user_images ,
           	'author' => $author ,
           	'text' => $text ,
           	'date' => $date
                   	);
       	$this->db->insert('comments', $data);
       	$c = json_encode($data);
       	echo $c;

Man vajag tikai pārbaudīt vai lauks nebija tukšs!!! Interesē, kā izvadīt no servera puses ? Un nodot json

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...