Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3968804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:53:13+00:00 2026-05-20T03:53:13+00:00

I’m getting this error when trying to post a form through an iFrame. In

  • 0

I’m getting this error when trying to post a form through an iFrame. In IE 8. in FF and Opera it works fine.

The short version of the problem is: I’ve got a complex form, which i use JavaScript to turn into a complex json object, and then i turn that into a json string. i add a form into the page with a hidden field for the json string, and clones of the file controls and submit that form w/ a target of my iframe.

Here’s my testing code:

    <div id="testingFormHolder">
<form id="IFrameSubmitForm">
    <input type="text" id='testText' name='testText' />
    <input type="file" id='testFile23' name='testFile' cfid="23" />
    <input type="file" id='testFile24' name='testFile' cfid="24" />
    <input type="button" id='testSubmit' name='testSubmit' />
</form>

</div>

<div id="TempFormHolder">

</div>
<div id="IFrameHolder" class="">

</div>

<script type="text/javascript">
    $(function () {
        $('#testSubmit').click(function () {
            var fileControls = $('#testingFormHolder').find('input[type=file]');
            var otherDataObject = { "field1": 'blah blah field 1', "field2": "field2" };
            var iframe = $('<iframe name="theIFrame" id="theIFrame" class="" src="about:none" />');
            var theFileNames = new Array();
            var thefiles = $('#testingFormHolder').find('input[type=file]');
            thefiles.each(function () {
                theFileNames.push({ cfid: $(this).attr('cfid'), FileName: $(this).val() });
            });

            otherDataObject.fileNames = theFileNames;
            var otherData = JSON.stringify(otherDataObject);

            $('#IFrameHolder').empty().append(iframe);

            var theForm = $('<form id="TempForm" name="TempForm">');
            fileControls.each(function () {
                theForm.append($(this).clone().attr('name', 'files').attr('id', $(this).attr('customFieldId')));
            });
            // theForm.append(fileControl.clone().attr('name', 'files').attr('id', 'file1'));
            theForm.append($("<input type='text' id='model' name='model' value='" + otherData + "' />"));

            theForm.attr('action', '<%= Url.Action(MVC.Temp.Actions.TestingFormSubmitThroughIFrame)%>');
            theForm.attr('method', 'POST');
            theForm.attr('enctype', 'multipart/form-data');
            theForm.attr('encoding', 'multipart/form-data');
            theForm.attr('target', 'theIFrame');
            $('#TempFormHolder').empty().append(theForm);

            theForm.submit();
           // $('#theIFrame').load(function () {


           // });

            return false;

        });

    });

</script>

i’m using asp.net mvc. while i was searching for an answer i came across a page that said something about mixing http and https but i’m just running it w/ local host. the address of the test page is:
http://localhost:60819/Temp/Testing/
and the ‘<%=Url.Action(MVC.Temp.Actions.TestingFormSubmitThroughIFrame)%>’ = “/Temp/TestingFormSubmitThroughIFrame”

edit: and changing the action to be the full address instead of just “/Temp/TestingFormSubmitThroughIFrame” didn’t fix it.

Thanks for the help!

Edit: Sorry about that, i thought it copied the entire error message! the full error message is:

“Navigation to the webpage was canceled”
“What you can try:
Retype the address.

“

that comes up in my iframe when it tries to submit. it doesn’t even attempt to make the post.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:53:13+00:00Added an answer on May 20, 2026 at 3:53 am

    Well, i switched to using the jquery.form plugin and it seems to work! I’m not sure what it’s doing differently. but i would suggest it to anyone, it’s pretty damn easy to use! I don’t know why i didn’t use it in the first place!

    Here’s what the code looks like now:

    <script type="text/javascript">
    
            $(function () {
                $('#testSubmit').click(function () {
                    var fileControls = $('#testingFormHolder').find('input[type=file]');
                    var otherDataObject = { "field1": 'blah blah field 1', "field2": "field2" };
    
                    var theFileNames = new Array();
    
                    fileControls.each(function () {
                        theFileNames.push({ CustomFieldId: $(this).attr('customFieldId'), FileName: $(this).val() });
                    });
    
                    otherDataObject.cfNames= theFileNames;
                    var otherData = JSON.stringify(otherDataObject);
                    $('#TempFormHolder').empty();
                    var theForm = $('<form id="TempForm" name="TempForm" action="http://localhost:60819/Temp/TestingFormSubmitThroughIFrame" />').appendTo('#TempFormHolder');
                    fileControls.each(function () {
                        theForm.append($(this).clone().attr('name', 'files'));
                    });
    
    
                    theForm.append($("<input type='text' id='model' name='model' value='" + otherData + "' />"));
    
                    theForm.ajaxSubmit({ target: '#ResultTarget' });
    
                    return false;
    
                });
    
            });
    
        </script>
    

    Hopefully That helps someone out in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.