0

Есть некий код, который отправляет файл на скрипт и получает var_dump($_FILES) в ответе.

 $(':button').click(function(){
        var formData = new FormData($('form')[0]);
        var myXhr = $.ajaxSettings.xhr();
        $.ajax({
            url: 'upload.php',  //Server script to process data
            type: 'POST',
            xhr: function() {  // Custom XMLHttpRequest
                if(myXhr.upload){ // Check if upload property exists
                    myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // For handling the progress of the upload
                }
                return myXhr;
            },
            //Ajax events
//            success: ,
            // Form data
            data: formData,
            //Options to tell jQuery not to process data or worry about content-type.
            cache: false,
            contentType: false,
            processData: false
        });
    });

    function progressHandlingFunction(e){
        if(e.lengthComputable){
            $('progress').attr({value:e.loaded,max:e.total});
        }
    }

Задача состоит в том, чтобы данные которые возвращает скрипт upload.php отобразились в блоке с id='1'.

Как это осуществить?

1 ответ 1

1

Если upload.php возвращает /html, то можно попробовать заменить

//            success: ,

на

              success: function(msg){
                $("#1").html(msg);
              },
1
  • Благодарен то как) О msg совсем забыл) Балда я :D +1 26 июл 2015 в 10:59

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.