Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have the following HTML code for my file upload

<div id="status"></div>

<iframe name="upifrm" src="" style="display:none;"></iframe>

<form name="myForm" id="myForm" action="upload.php" method="post" enctype="multipart/form-data" target="upifrm">
<label for="fileinput" id="brsbtn" class="labtrigg">label</label> 
<input type="file" id="fileinput" name="file" />
</form>

<div id="atchs"></div>

and at the end of my upload.php file I have

// . . . . . . . . . . . . .     
// $message declaration . . .

echo '<script>
parent.document.getElementById("myForm").reset(); 
parent.document.getElementById("status").innerHTML="'.$message.'";
$("#atchs", window.parent.document).after("<span>something</span>");
</script>';

the first two lines work perfectly (they are written in pure Javascript code), but I get the error on the third line

$("#atchs", window.parent.document).after("<span>something</span>");

"Object expected". How can I solve this problem?

share|improve this question
you call $("#atchs", window.parent.document).("<span>something</span>"); in your iframe ? do you have jquery included in the iframe ? – t.niese Apr 27 at 13:55
Your first two lines are of conventional js why are you using jQuery method on third line ? – Rikesh Apr 27 at 13:57
I have included jQuery on my main HTML file. Iframe is on this HTML file. Rikesh, I want to rewrite whole code in jQuery, so above code is just an example. Thank you. – Paramore Apr 27 at 14:01
window.parent.document < are you sure that this doesn't result in undefined? – bwoebi Apr 27 at 14:02
Bwoebi, yes I'm sure. I tested it – Paramore Apr 27 at 14:05

2 Answers

up vote 0 down vote accepted

try this one Make sure in your parent page youhave included jQuery file

top.jQuery("#atchs").html("<span>something</span>");

hope this makes sense

share|improve this answer
Thank you very much Dianuj! – Paramore Apr 27 at 14:14
you are welcome :) – dianuj Apr 27 at 14:33

Even if you have jQuery included, there should be a function name here:

$("#atchs", window.parent.document).("<span>something</span>");
                                    ^^^

Something like append, prepend, html, text, or whatever you're trying to do. It cannot be just a dot and parentheses.

share|improve this answer
Oh, sorry, I edited my post. I missed it – Paramore Apr 27 at 14:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.