How to insert tags into database using jquery html and php

I want to insert these particular tags into the database. This is my HTML:

<div id="tags">
    <input type='text' name='tags' placeholder='Type in topic tags here seperated by commas' id="tagg" />
</div>

and the jQuery part:

 counter = 0;
    $(function(){
        $('#tags input').on('focusout',function(){    
        var txt= $.trim( $(this).val() ).replace(',','');
        if(txt){
        $(this).before('<span class="tag"  name="tags[]" value="'+txt+'">'+txt+'</span>');
        counter++;
        if(counter==5){
            $('#tags input').prop('disabled', true);
        }
        //$(".bgtopic").append("<input type='hidden' name='tags[]' />")
        //Yet to implement the counter varibale to be visible...
    }

    $(this).prop('value','');  
  }).on('keyup',function( e ){
    if(e.which==188){
      $(this).focusout(); 
    }
  });

  $('#tags').on('click','.tag',function(){
     $(this).remove();
     counter--;
     $('#tags input').prop('disabled', false);

  });

});

What the piece of code creates a tag when a user is creating a new post on my forum, just like the way it is here on StackOverflow. I want to be able to store the tags so that I can use them to create a tag cloud. How can I accomplish this?

Answers:

Answer

you have to do an ajax request via jquery.

you can find a lot of tutorials on web how to do that (e.g. http://www.ibm.com/developerworks/opensource/library/os-php-jquery-ajax/)

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.