Can I stop dompdf page hard reload in laravel dompdf? - dompdf

I have used dompdf in my laravel application and I'm calling the pdf generate function from the same form submit button and both are working fine. The only issue I'm facing right now is on my generated pdf file every hard refresh/reload, form data is submitting again to the database. Is there any possible way that i can prevent that reload or form submit?
I tried with this below Jquery but that completly prevent my form by clicking the button also. I just want that form not to submit again on pdf file reload.
$("#orderForm").submit(function(e) {
e.preventDefault();
});

Related

Django - download file without reloading the page

The flow looks like that:
user is filling the form
form is passed to the server by ajax
form is saved to db, then the pdf with the form data is created and saved in the app folder (probably a bad move here...)
ajax success causes the page to append a button 'Download' with value equal to current pdf's name so button 'Download' appears to the user
If user presses the button the very pdf that was just saved is gonna download.
Refreshing the page makes the button disappear.
I've got stuck on point 5. I have created another ajax (to avoid reloading the page) bound to the Download button. It correctly asks the server to look for the file, creates a django File object: pdf_file = File(open(file_path, 'rb'))
and creates a HttpResponse with file, and content_type='application/pdf' or 'application/download'.
response['Content-Disposition'] is attachment.
Then the ajax returns response - only it does not. Server raises no error but ajax error function is called.
I've read that downloading with ajax is not possible. Could you help me a bit to get it straight? If above snippets are not clear, I shall provide more code.
Python 3.5, Django 1.10
Do like
window.location.href = "/url/to/downloadfile/"
in javascript after success of posting form. OR
#html
<button onclick="myfiledownload()">Download</download>
#javascript
function myfiledownload(){
window.location.href = "/url/to/downloadfile/"
}
Instead of using ajax to download the file bind the button to a download link where the file may be hosted
https://www.mywebsite/download/?fileid=3247023
You should at least seperate your file in a media root
Note: in production you will have to use a cdn to host your static files

add uploadify upload function to form submit button

I am using Uploadify uploader for my form submission which include some other text field. I set the auto upload to 'false' so that I could trigger the upload process of all the files user have chosen when the form submit button is clicked which would submit both the files and data in the text field to my DB.
But I couldn't figure that out. please help me on this.

Form submission inside ajax

In my application on a button onClick, I am loading a form in an overlay using ajax. But this for submission is not redirecting to the required page.
I have tried the same form element without ajax and overlay, then it is working fine. So there is no problem with the form element. I think I am missing some settings to invoke form submission inside ajax.
I am using Web2py application.
I would greatly appreciate any suggestions.
EDIT:
I have one more similar question. I am displaying a web2py SQLFORM for a db-table in an overlay using ajax. The form submission and data update is working fine. But after the form submit I want to close the overlay and reload the page. Right now, it is showing 'Server Error' inside the overlay. I am using LOAD() to load the form on overlay.

How to page refresh after page redirect in Jquerymobile MVC

Hi all i have create a small jquerymoblie mvc3 aplication in that i have a list-view controle when click on the link in the list-view it render to the next page, in that page i have upload some data into database using text-boxes.After updated completed i have redirect to the previous page,Now i again redirect to same page for upload some other data but the text boxes fields are not clear it shows old data how can i clear that data when i page redirect.
I am using jquerymobile mvc3(Razor) application please help me how can i solve this probles..
If you go back to the "list page" with:
$.mobile.changePage("/control/list/", { reloadPage: true });
It should reload the page from scratch with AJAX.
There are also several more options for the changePage method which you can find in the docs: http://jquerymobile.com/test/docs/api/methods.html

how to return to ajax enviroment after upload a file using iframe

hi im working into a full ajax enviroment page, but i have the need to upload a file into my app, i used an iframe to "display" my form to upload (since i cant upload a file using pure ajax enviroment) but when i try to return to my ajax enviroment i cant get the view that i need, i keep locked "inside" the iframe, any ideas how to get out of the iframe and continue my app processing?
or an alternative to do this using jquery?
thanks a lot Mitzato
edit
im using rails 3
some html5
and ajax
You could update a div in the parent of the iframe with the response you get in the iframe using the top.document, like:
$("#myid", top.document);
You would need to include jquery.js in the iframe...
Well the final solution was to create a parent div and in another view create the iframe, then insert my form into my iframe, and finally I add and script in the botton that deletes the div where the iframe is contained that returns me to my ajax environment.

Resources