i try to do a jquery modal form. the problem is, i include myform.php into the jquery's DIV.
the reason why i put myform.php into jquery's div because i want the php do some input validation/checking exiting data in the database instead of using jquery validation. everything works fine. But the problem is, after i save the data, and the modal was close, then i try refresh the page. then i will get some message saying that "Retry to submit.. blabla..bla..bla..." how to avoid this message? or is there any way to integrate php form with PHP??
You could try and not submit the form and send the $_POST data through AJAX .
i think the new page added to current page div element
may be you should clear the content of div element after closing dialog
Related
I'm using ajax to create list of replies.
In the end of the list I added textarea form that allow user to add reply (also with ajax).
The problem is that i call to my JS in my main PHP page so when user want to submit reply the page doesn't "know" the js code. If i add the js to the ajax php file/page the code will work but then it will be duplicated many times and when user will submit form the text will be submitted many times...
In my console i see that the JS file duplicate every time i load the replies list
How can i prevent it?
Disable the submit button right after user presses it once. Using jQuery:
$("#button").attr('disabled','disabled');
Make sure to remove disabled attribute on AJAX error so user can re-submit the form with new data. You can remove disabled attribute like this:
$('#button').removeAttr('disabled');
[improved]
if you want to not repeat data when navigation or F5 press, simply free the $_POST vars after doing whatever you want, and check if isnt set (before clean, of course) redirect you wherever you want. example:
/* HERE do the job with ajax response. */
if(!isset($_post['foo'])) header('Location: wherever.php');
$_POST['foo']=NULL;
If you're using $_GET... don't do it, use $_POST... $_POST is your friend.
Finaly ensure that if you press F5, you don't re-send form vars by post (otherwise you will get the same). If it's happening, clear your inputs with jQuery on page load.
$('#inputID').val('');
i am using laravel and jquery to make my website, i'm using the jquery .load method to fill a div in a page:
$('#button').on('click',function(){
$('#container').load('url');
});
it's working fine but it's filling the container with a form, and when i submit the form if the validation passes everything it's ok because i don't need to show the form again, but if i want to return some errors i have to click the button again to show the form again.
Is there a way to just load the page with the .load() i allready had?
I have made a simple home-made lightbox. The lightbox contains forms which allows the user to submit data. I placed a SIMPLE form on my SIMPLE lightbox, and I noticed that when I submit the form the lightbox closes automatically. Why is it doing this, and how can I keep this from happening? I'd like to submit a form on the lightbox and keep the lightbox unaffected.
this is not possible if you submit the form using php it will submit to another page so it will refresh if you want to stay on the page you will have to look into using AJAX to submit the form and get the server response
There are some good technology's out there to do this like jquery AJAX
http://api.jquery.com/jQuery.ajax/
I'm making this contact form. The site itself uses AJAX to load the content in the main window. The problem with my form is that when the user clicks on submit and the data passes validation, it loads the page to main instead to itself to reach the actual mailing script.
Is there any way to pass this??
take the action our of the form opening tag
If you're using the Prototype.js library, you could just call event.stop() on a passed event object, on form submit.
Hi I am using php and i want to submit form on onclick event of radio button.
when form submission is done, than after I want to reload my page.
Means first form is submitted and after form submit I want to reload my page again.
Is it possible?
I have tried it with javascript but not get any idea how to do it..
Thanks in advance.
header('Location: http://url.to/reload');
exit;
Make sure to do this before any output on that page otherwise you'll get an error about headers already having been sent.