我想提供一個可嵌入的JavaScript,它將從我的服務器獲取腳本。而後者會從用戶(我的可嵌入式js的頁面)中獲取一些細節並將其放回到我的服務器上。我如何去實現這一點。腳本標記破解+如何在AJAX的第二級之後進行通信
這是我提供的可嵌入式js。
<script>
(function() {
read="This is the data which is entered by the user";
var istreet = document.createElement('script'); istreet.type = 'text/javascript'; istreet.async = true;
istreet.src = 'http://xyz.com/a.php;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(istreet);
})();
</script>
$('<div id="content"></div>').appendTo('body');
$('#content').html('
Some html to inject to the page\'s dom .
');
$.get("http://xyz.com/process.php?dataToProcess="+read,function(data){
alert(data);
});
代碼,但我看到,$獲得( 「http://xyz.com/process.php?dataToProcess=」 +閱讀功能(數據){// 導致跨域Ajax請求
我不想解決跨域AJAX的問題。 我希望能夠與嵌入腳本雙方一間(通信和我的服務器)無縫地。