Hello. I am using an iframe in my page to submit a form to so that it can upload a file - since you can't do this through the jquery ajax function. I have everything working, but I want to be able to hide the iframe and get the content of it, and put just the content inside of it into another div on the page.

I have tried alot of things, but I think this one was probably closest:

$("#myframe")[0].contentDocument;

This ended up getting me a value type of "Object HTMLDocument", I just can't figure out how to get the content as a string so that I can put it into the div I want.

Thank you for any help you can give me!

I have continued to look around for a solution, and I re-ran my page again and realized that I was being alerted of the iFrame content before that content was in the iFrame to begin with. So what I did was looked to see if the iFrame had been completely loaded, then I got the content and put it where I wanted it.

Code:

function getIframeContents(){
	$("#fileuploadframe").load(function(){
		response = $("#fileuploadframe").contents().find("#returnValue").html();
		alert(response);
		$("#responses").html(response).show();
	});	
}

This function is fired onsubmit of a form.

fail... please delete

d

can anyone give the correct answer

it diddnt work. How to get json response from iframe load function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.