How to post data to iframe with Jquery

后端 未结 3 374
抹茶落季
抹茶落季 2020-12-30 08:06

How can I dynamically post data to an iframe in Jquery.

I really need to post data to an Iframe in this case, I cannot use a $.POST because data received is returned

3条回答
  •  孤城傲影
    2020-12-30 08:48

    This function creates a temporary form, then send data using jQuery :

    function postToIframe(data,url,target){
        $('body').append('
    '); $.each(data,function(n,v){ $('#postToIframe').append(''); }); $('#postToIframe').submit().remove(); }

    target is the 'name' attr of the target iFrame, and data is a JS object :

    data={last_name:'Smith',first_name:'John'}
    

提交回复
热议问题