var x = 5;
var body = 'x=' + x;
req.open("POST", 'ip.php', true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(body);
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="" />