logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ how to upload files asynchronously using jquery?

HOW TO UPLOAD FILES ASYNCHRONOUSLY USING JQUERY?

by Admin _ May 10, 2022
darkedeneurope.com : Getting StartedUsing darkedeneurope.comUsing darkedeneurope.com PluginsUsing darkedeneurope.com UIDeveloping darkedeneurope.com CoreDeveloping darkedeneurope.com PluginsDeveloping darkedeneurope.com UIQUnit và TestingAbout the darkedeneurope.com darkedeneurope.comdarkedeneurope.com Conferencesdarkedeneurope.com MobileDeveloping darkedeneurope.com Mobile

Bạn đang xem: How to upload files asynchronously using jquery?

*

Xem thêm: Tt In Advance Là Gì - Phân Biệt Tt Và Ttr Trong Khai Báo Hải Quan 2021

Hello again,I am trying to lớn create a possibility for users to lớn 1) select an image using an input field --> the image is displayed in a preview box by the function readURL --> that works fine2) upload that image to process máy chủ side wise by clicking a div calling a function uploadImage --> HERE IS THE PROBLEMThe html code:

No tag around used. Also functions are called on events --> both function give at least a response when I for examploe trouble shooting using alert();

$( '#imgInput' ).change( readURL ); $( 'div#submitAddImage' ).on( 'click' , uploadImage ); With the readURL function I am creating an object using FileReader mechanism. The tệp tin is then displayed in $( 'img#previewWindow' ).var myFile = ''; function readURL( e ) if ( this.files && this.files<0> ) var reader = new FileReader(); reader.onload = ( function( e ) $( 'img#previewWindow' ).attr( 'src' , e.target.result ); ); reader.readAsDataURL( this.files<0> ); myFile = this.files<0>; // store file in global variable Clicking the div-Button executes the upload funtion.function uploadImage() var data = new FormData(); $.each( myFile , function( key , value ) data.append( key , value ); ); $.ajax( url: 'changeUploadImage.php', type: 'POST', data: data, cache: false, dataType: 'json', processData: false, contentType: false, success: function( data , textStatus , jqXHR ) if( typeof data.error === 'undefined' ) submitForm( event, data ); else alert( 'ERRORS: ' + data.error ); , error: function(jqXHR, textStatus, errorThrown) alert( 'error on upload' ); ); THE RESULT IS THAT I over UP WITH THE ALERT 'error on upload'. So the upload fails. I don't understand also after long trying how to create an object (don't know for example how to show me the object, what are to lớn properties lượt thích path, type, image itself,...) và then lớn pass over to lớn the ajax function lớn uplaod. I also vì chưng not understand, whether I need the each function for the maFile variable. I thought I have profund skills using darkedeneurope.com, but connot master this issue, which sucks!So what is it exactly that creates me the object và how can I pass on to another function?Can someone help? I am thinking already about trying other approached discarting the ajax upload function. But that would be even more frustrating...Thank you in advanceFrank
Share Tweet Linkedin Pinterest
Previous Post

Get value input file jquery

Next Post

Jquery disable button on click to prevent multiple form submits

CÙNG CHUYÊN MỤC

jquery file upload (hayageek plugin) error case with json from php

Jquery file upload (hayageek plugin) error case with json from php

28/04/2021
search/filter table rows based on input

Search/filter table rows based on input

28/04/2021
jquery form validation before ajax submit

Jquery form validation before ajax submit

18/03/2021
jquery multiple select dropdown

Jquery multiple select dropdown

28/04/2021
jquery form validation before ajax submit, easy form validation with jquery

Jquery form validation before ajax submit, easy form validation with jquery

25/05/2022
top 17 jquery foreach json array hay nhất 2022

Top 17 jquery foreach json array hay nhất 2022

24/05/2022
how to upload files asynchronously using jquery?

How to upload files asynchronously using jquery?

23/05/2022

22/05/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • 12 cung hoàng đạo làm gì cuối tuần

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.