function saveImg(image) { var _this = this; var url = document.getElementById('finish').href; $.ajax({ type: 'POST', url: '/oek_temp/upload.php', data: {image: image}, success: function (resp) { _this._displayStatus('Image saved successfully'); window.location.href = url; } }); } $('#wPaint').wPaint({ path: '/static/js/wpaint/', bg: '#ffffff', menuOffsetLeft: -35, menuOffsetTop: -50, menuOrientation: 'horizontal', saveImg: saveImg });