javascript - AJAX no output after evaluation through if-statements -
so i've got file index.php gives form upload image.
<!doctype html> <html> <head> <title>unnamed</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- include styles --> <link href = "bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href = "css/style.css" rel="stylesheet"> <!-- include jquery --> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <!-- include form plugin --> <script src="http://malsup.github.com/jquery.form.js"></script> <!-- javascript --> <script> // wait dom loaded $(document).ready(function() { // bind 'myform' , provide simple callback function $('#insert_movie').ajaxform(function() { $('#message').load('upload_file.php'); }); }); </script> </head> <body> <!-- message banner --> <div id='message'></div> <!-- insert movie database --> <h1>add new movie list</h1> <form id="insert_movie" action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">filename:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" value="submit"> </form> </body> </html>
note: might not familiar guys, i've used plug-in jquery in order easy ajax-ing. might want check link
i evaluate form via upload_file.php:
<?php error_reporting(e_all); //upload image $allow = array("jpg", "jpeg", "gif", "png"); $todir = 'images/'; if(isset($_post['submit'])){ if ( $_files['file']['tmp_name'] ) // file uploaded yet? { $info = explode('.', strtolower( $_files['file']['name']) ); // whats extension of file if ( in_array( end($info), $allow) ) // file allowed { if ( move_uploaded_file( $_files['file']['tmp_name'], $todir . basename($_files['file']['name'] ) ) ) { echo "great"; } } else { // error file ext not allowed echo 'choose file extension'; } } } echo "this works"; ?>
so problem nothing beside "this works" ever rendered in tags. upload performed perfectly.
all appreciated!
edit: when forget ajaxing , redirected upload_file.php, gets rendered fine...
the problem form send via ajaxform upload_file.php , should work fine in call returning expected string. server response callback function called , here call upload_file.php again without parameters , render result in div, "this works" . should use plugin following:
$('#insert_movie').ajaxform({ success: function(response) { $('#message').html(response); }});
Comments
Post a Comment