0

hii i am using ajax file upload in this code

 <script type="text/javascript" src="fileuploader.js"></script>
   <script type="text/javascript" src="jquery-1.4.2.min.js"></script>

<div id="photo_upload">
      <div id="file-uploader_photo">       
       <noscript>          
       <p>Please enable JavaScript to use file uploader.</p>
       <!-- or put a simple form for upload here -->
       </noscript>         
      </div>
     </div>

<script language='javascript'>
new qq.FileUploader({
   element: $('#file-uploader_photo')[0],
   action: 'upload.php',
   onSubmit: function(id, fileName){
    ContentWindow.params['title'] = fileName;
    CDNAPI.validate(ContentWindow.params);
    ContentWindow.uploader.setParams(ContentWindow.params);
   },
   onComplete: function(id, fileName, content_data){
    // create content object in Gib
    App.addNewContent(content_data);
   },
   template:'<div class="qq-uploader">' + 
    '<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' +
    '<div class="qq-upload-button ui-widget-content ui-button ui-corner-all ui-state-default">Upload files</div>' +
    '<ul class="qq-upload-list"></ul>' + 
        '</div>'
  });
</script>

but this code is giving me error this._element is undefined [Break on this error] if (this._element.nodeType != 1){

please tell me what is the problem

using this one ...http://valums.com/ajax-upload/

1
  • I make the assumption here that your: fileuploader.js does Not use jQuery. Commented Sep 23, 2010 at 12:03

1 Answer 1

1

There is no id="file-uploader" element in your question, did you mean to do this instead?

element: $('#file-uploader_photo')[0],
//or without jQuery at all:
element: document.getElementById('file-uploader_photo'),

You can give it a try here.

Sign up to request clarification or add additional context in comments.

9 Comments

@Rahul - It's working here with only that change: jsfiddle.net/nick_craver/mwDb8 you sure you don't have the file cached or anything?
or perhaps element: $("div[id^='file-uploader_']")[0],
@Mark - Since you're using a [0] indexer it should be an exact/single match here ;) I would actually argue to leave jQuery out of it altogether, just document.getElementById("file-uploader_photo")
@Nick Craver - yes, I looked at that as well, but was making no assumptions regarding the rest of the code after viewing his code. Probably a good idea here for your snippit as well since the [0] does return that singleton. Seems like a wierd error and I wonder if there is some other issue in the full context of the code.
@Rahul - Is the demo I posted working for you? If so there's something in addition to your question affecting this, is the code exactly as you posted? Try replacing $('#file-uploader_photo')[0] with document.getElementById("file-uploader_photo") just to take jQuery completely out of the picture.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.