1

I am Trying to upload file without reloading or redirecting page to other page.
I have tried...

upload.php

<form enctype='multipart/form-data' action='/' method='POST' class="AjaxSubmit" id='newwork' name='newwork'>
    Choose New Work<br />
    <input name='uploadednewwork' type='file' /><br />
    <button id="btnFrmPost1" class="button" onclick="up()" >New Work</button>
</form>

script.js

    function up() {  
  $('#btnFrmPost1').click(function() { 
            event.preventDefault();
            var $form = $(this);
            var url = "/subpages/upload_new_work.php";
            var data = $form.serialize()
            $.ajax({
                type: "POST",
                dataType: "json",
                url: url,
                data: data,
                success: function (resp) {
                    var jdata = eval(resp);
                    var $jAlrtSuccess = $('<div>' + jdata.responseText + '</div>');
                    $($jAlrtSuccess).dialog({modal:true});
                },
                error: function (xhr, status, error) {
                    var $jAlrtError = $('<div>' + xhr.responseText + '</div>');
                    $($jAlrtError).dialog({modal:true});
                }
            });
        return false;
    });
   }

I have tried all this code...
but i wont get result...
can any one please tell me how to solve this problem...

Sarvesh Godbole
  • 89
  • 1
  • 2
  • 6

0 Answers0