php - Code never executed, not getting any errors -


i trying use ajax , html5 handle file uploads clients computer folder on server.

right alert message below in addition success function never executed , not sure why. not getting js errors. both php script , folder save file granted full read/write permissions.

it extremely difficult me work without seeing errors.

i appreciate assistance in identifying cause of problem, , getting errors or @ least alert message execute.

many in advance!

jquery

    $.ajax({         url: 'upload.php',  //server script process data         type: 'post',         xhr: function() {  // custom xhr             myxhr = $.ajaxsettings.xhr();             if(myxhr.upload){ // check if upload property exists                 myxhr.upload.addeventlistener('progress',progresshandlingfunction, false); // handling progress of upload             }             return myxhr;         },         //ajax events         success: function(data){             alert("ok");             $('body').html(data);         },         // form data         data: formdata,         //options tell jquery not process data or worry content-type         cache: false,         contenttype: false,         processdata: false      }); 

html

    <form enctype="multipart/form-data">     <input name="file" type="file" />     <input type="button" value="upload" />     </form>     <progress></progress> 

upload.php

<?php if ($_files["file"]["name"] != null) {   if (file_exists("uploads/" . $_files["file"]["name"]))     echo $_files["file"]["name"] . " exists. ";   else     move_uploaded_file($_files["file"]["tmp_name"], "uploads/" . $_files["file"]["name"]); }   ?> 

add error handler well.

$.ajax({   success: function(data){     console.log("ok");     $('body').html(data);   },   error: function(xhr, textstatus, errorthrown){     console.log('an error has occurred!');     console.log(textstatus);     console.log(errorthrown);   } }); 

javascript won't throw errors failed ajax request, need catch them yourself.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -