function saveImg(image) { var _this = this; var url = document.getElementById('finish').href; var save_url = document.getElementById('wPaint').dataset.save; $.ajax({ type: 'POST', url: save_url, 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 });