Search code examples
phpajaxtag-it

tag-it: save to database?


I'm using Tag-it, and I'm trying to save the added tags into my database (with ajax and php). This is what I got:

$(document).ready(function() {
    $("#myTags").tagit({
        afterTagAdded: function(event, ui) {
                        $.get("/addtag.php", { tag_content: "TAG_CONTENT" });
                        }
    });
});

addtag.php:

$TAG_CONTENT = $_GET["tag_content"];
mysql_connect("xxx", "xxx", "xxx") or die(mysql_error());
mysql_select_db("xxx") or die(mysql_error());
$query = sprintf("INSERT INTO test (tags) VALUES ('%s');", $TAG_CONTENT);
mysql_query($query);

But how can I save the "real" tag? How do I get the value? Right now it, ofc, just saves the string "TAG_CONTENT"

Thanks in advance.


Solution

  • you are looking for

    $.get("/addtag.php", { tag_content: ui.tag });
    

    or

    $.get("/addtag.php", { tag_content: ui.tagLabel });