$(document).ready(function(){

$("#nieuwsbriefForm").submit(function(event) {
   
    // stop form from submitting normally
    event.preventDefault(); 
        
    // get some values from elements on the page:
    var $form = 			$( this ),
    	email = 			$form.find( "input[name='tfEmailNieuwsbrief']" ).val(),
        url = 				$form.attr( "action" );

	// Send the data using post and put the results in a div
    $.post( url, {
      scriptCharset: "utf-8" , 
      contentType: "application/json; charset=utf-8",
      tfEmailNieuwsbrief: email
    },function( result ) {
 			if(result.success){
              $('#nieuwsbriefText').html(result.message);
            } else {
           	  $('#nieuwsbriefError').html(result.message);	
           	  $('#tfEmailNieuwsbrief').css("border", "1px solid red");
            }
      	},'json'); // end post
    
    
    
  });


});
