title: How to get uploaded images from Parse using javascript API
body: <p>Problem:</p>
  
  <p>I have the Url (eg. <a href="http://files.parse.com/../../..jpg" rel="nofollow">http://files.parse.com/../../..jpg</a> ) of the uploaded file and it's fileName, and now need to retrieve the corresponding file from that Url(Parse.com) by using Only via Javascript . Any one have the answer let me know. Thank you very much!</p>
  
  <p>Code: (upload):</p>
  
  <pre><code>function uploadFn(fileName,fileType,fileData,c){ 
          var parseUrl='https://api.parse.com/1/files/'+fileName; 
  $.ajax({
          type:'post',
          beforeSend:function(req){
                  req.setRequestHeader('X-Parse-Application-Id',myParseAppId);
                  req.setRequestHeader('X-Parse-REST-API-Key',myParseRestApiId);
                  req.setRequestHeader('Content-Type',fileType); // fileType always == 'image/jpg;'
              },
          url:parseUrl,
          data:fileData,
          processData:false,
          contentType:false,
          success:function(rslt){
              if(rslt){
              alert('Upload success\n Filename:'+rslt.name+'\n Url:'+rslt.url);
                      imgObj.save({curUser:curUser,fileName:rslt.name,fileUrl:rslt.url,fileId:c},
                                  {success:function(succ){
                                      alert('File info saved!');
                                      },error:function(err){ 
                                          alert('Error:'+err.code);
                                          }
                                  }) // save
  
  
                  }
              },
          error:function(err){
                  //var errObj=jQuery.parseJSON(err);
                  alert('Error:'+err.responseText);
              }
      });
    }
  </code></pre>
  
  <blockquote>
    <p>upload is not a problem. It works fine! Only for retrieving from Parse.com</p>
  </blockquote>
  
  <p>(toRetrieve) [I tried as: ]</p>
  
  <pre><code>function fetchImg(url){
    $.ajax({
     url:url,
     async:false,
     type:'POST',
     beforeSend:function(req){
          req.setRequestHeader('X-Parse-Application-Id',myParseAppId);
          req.setRequestHeader('X-Parse-REST-API-Key',myParseRestApiId);
          req.setRequestHeader('Content-Type','image/jpg');
      },
     complete:function(rslt){
          $('#imgId').attr('src','data:image/jpg;base64,'+rslt.responseText);
      },
     success:function(){//Success
      },
     error:function(err){
          alert('Error: '+err.responseText+'\nStatus: '+err.statusText);
      }
     })
    }
  </code></pre>
  
  <p><strong>[output:]</strong></p>
  
  <p>'Error-msg>The specified method not allowed against this resouce' Status: Method Not allowed!.</p>
  
  <p><strong>Notes:</strong> ¤ (I saved the fileName, fileUrl to the Parse DataBrowser, and used this for try to retrieve the uploaded file.)</p>
  
  <p>¤ (App is based on 'Phonegap')</p>
  
  <p>¤ Im novice to Parse/Javascript.</p>
  
  <p>Thanks a lot! <strong><em>*</em></strong></p>