How do you post to an iframe?

前端 未结 4 2118
慢半拍i
慢半拍i 2020-11-22 00:55

How do you post data to an iframe?

4条回答
  •  执念已碎
    2020-11-22 01:23

    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'}
    

提交回复
热议问题