0
我有以下提交给iframe的jquery函数。从PHP发回的消息是json。我无法弄清楚如何在jQuery中接收此消息,以便我可以将其显示给用户。jquery从PHP接收json消息
function IframeSubmit(){
// remove iframe if exists
$('#hiddenIframe').remove();
// change target attribute on form
form.attr('target', 'hiddenIframe');
// create and add iframe to page
$('<iframe />', {
name: 'hiddenIframe',
id: 'hiddenIframe',
style: 'display:none'
}).appendTo('body');
// on response from php file
$('#hiddenIframe').load(function(){
// process received message here ...
});
}
谢谢!
使用ajax,echo a json obj通过php'json_encode($ string);' – gorelative
'.load()'方法用于将html内容加载到元素中,而不是JSON。尝试使用['.getJSON()'](http://api.jquery.com/jQuery.getJSON/),并在回调中处理结果。 – nnnnnn
错误:getJSON()不是函数。 – user1002039