var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://www.domain2.com:8080/login?user=admin&callback=onBack'; document.head.appendChild(script); function onBack(res) { alert(JSON.stringify(res)); } onBack({"staus":true,"user":"admin"})