I am currently making a script, which should work as following: When you click a button the knob next to the button should insert a value. This have to be done in real time. So, now I would like to know what I should use for this. I researched a little and came up with ajax or socket.io, but which is better?
Some code:
<input class="knob" value="0" readonly data-width="80%">
<div class="button">
<a class="md-btn md-btn-success">Click me</a>
</div>
Animation for knob:
<input class="knob animated" value="0" readonly data-width="80%" rel="<?php echo $number; ?>">
<script>
$('.knob').each(function () {
var $this = $(this);
var myVal = $this.attr("rel");
$this.knob({});
$({
value: 0
}).animate({
value: myVal
}, {
duration: 2000,
easing: 'swing',
step: function () {
$this.val(Math.ceil(this.value)).trigger('change');
}
})
});
</script>
I got the animation for the knob in another file and it works when I refresh, so I just have to get it into the real page.