English 中文(简体)
fancybox ajax post to iframe
原标题:

is it possible using fancybox to post a var to the iframe when opens?

I currently have:

function fancyBoxLoad(element) {
    var elementToEdit = $("#" + $(element).attr("class"));
    var content = encodeURIComponent($(elementToEdit).outerHTML());
    $.fancybox(
        {  href :  loadEditor.php  },
        {
            frameWidth: 750,
            frameHeight: 430,
            overlayShow: true,
            ajax: {
                type: "POST",
                data:  content=  + content
            },
            type:  iframe 
        }
    );
}

It does seem that if I take away type: iframe it will post data but it doesn t appear to be in the iframe and if I take away ajax: { type: "POST", data: content= + content } instead it will open in an iframe but not post the data (the example above does the same)

So my question being can it be done?

问题回答

If you re simply trying to put content in a iframe, why don t you use fancybox to create the iframe, and once you know it s been created, then access it via the reference that fancybox returns to you and set your content that way. I m not sure you want to send the content to the server and back. Just wait for the iframe to load, then on ready, query an element within it and set the content.

Looking at the source for Fancybox v1.3.1 they are in fact mutually exclusive. If you don t feel comfortable diving into the source code and editing the plugin, you might try using GET variables in your HREF as a work around. It should effectively work like a post as it is an AJAX call, just make sure the backend can receive the GET variables.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签