我正在尝试从我的AngularJS
应用程序中运行的iframe发回数据。为此,我使用postMessage()
函数。
在我的AngularJS
控制器中,我有以下内容:
$($window).on("message", function (e) {
var message = JSON.parse(e.originalEvent.data);
console.log("my message: " + message);
});
在iFrame
我有这个:
window.parent.postMessage("This is coming from response.php","http://site123.com/test/proto");
但是当我在控制台中检查时,我看到了这个错误:
VM4132:1 Uncaught SyntaxError: Unexpected token T
当我更详细地查看它时,我发现违规行是这样的:
This is coming from responsephp
有谁知道为什么会这样?我很感激任何帮助。