javascript - Can't add notice after xhr request. Rails -


The file is added and correct redirects, but without notice, if you do not use EXHOR, the notice shows.

application.js

  var files = evt.target.files || Evt.dataTransfer.files; // files file is a filelist of the object to list some properties (var i = 0, f; f = files [i]; i ++) {var xhr = new XMLHttpRequest (); Xhr.open ("post", 'report_drag', wrong); Xhr.setRequestHeader ("content-type", "text / plain; charset = UTF-8"); Xhr.setRequestHeader ("X_FILENAME", "file." + F.name.split ('.'). Pop ()); Xhr.setRequestHeader ('X-CSRF- Token', $ ('meta [name = "CSRF-token"]'). Attr ('content')); Xhr.send (f); }   

Administrator .bb

  Diff report_ drag filename = "report / # {DateTime.now.year} - # DateTime .now.month} / "+" # vendor: where (id: current_user.id) .first.title} "+" # {file.extname ("# {request.headers ['HTTP_X_FILENAME']}")} "File. Open file (file name), "wb") {| F | | F.write (request.body.read)} redirect_to report_url, notice: "ФР° йл Ñ ?? Ñ ?? пÐμÑ ?? но Ð'оР± Ð ° вРÐμн. "End    

When you make a simple request from the browser (using a link) or button , or simply typing in the address bar), the response changes the current page and is rendered instead.

When you do not change the current location of the XHR , the browser does not render anything - it assumes that the caller (JavaScript code) is responsible for reading the response, And it's going to figure it out.

If you want to communicate with the asynchronous server, and use your answers to the page's re-render, read it

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -