views:

58

answers:

1

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/

A: 

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.

Nick Craver
ya i have change this but still the error is same.
Rahul Mehta
@Rahul - It's working here with only that change: http://jsfiddle.net/nick_craver/mwDb8/ you sure you don't have the file cached or anything?
Nick Craver
or perhaps element: $("div[id^='file-uploader_']")[0],
Mark Schultheiss
@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
@nick but it is giving the same error in my firefox browser what should i do ..
Rahul Mehta
@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.
Mark Schultheiss
@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.
Nick Craver
@Mark - good point, I updated the snippet and demo here as well.
Nick Craver
@nick not working still
Rahul Mehta
@Nick Craver - I get a "ContentWindow is undefined" error in your fiddle if I click the button.
Mark Schultheiss
@Mark - Sounds like a plugin error, which browser and are you running extensions/addons/plugins?
Nick Craver
I am using IE8 in compatibility mode. Only have the f12 developer add-in for that nothing else. His markup template:xxx bothers me a bit, seems to be jQuery UI, but that is not in the sample. I also pause when it is not wrapped given the jQuery selector. I examined the plugin link and no "template:" is in those examples.(enough of my random thoughts already :)
Mark Schultheiss