var text = $.trim($(this).val()); var $this = $(this); if(text.length > 2) { $.ajax({ url : "/model/tags_autocomplete.php", type : "post", dataType: "html", data : ({text : text}), success : function(data) { $this.after(data); } }); }