Error after form submission in JQuery Mobile - php

I am using JQuery Mobile and submitting a form in it. The form is submitted via post method and is sent to a php file. The form is getting submitted without any problem and submitted data is displayed in the php page. But once I refresh the page, I am getting Undefined index notice and the data is gone. The dialog window asking me for form re submission confirmation,like it normally does on refreshing is also not coming.

This is because jQuery mobile is sending the form via AJAX and not doing a normal POST request.
In jQuery Mobile, form submissions are automatically handled using
Ajax whenever possible, creating a smooth transition between the form
and the result page.
http://jquerymobile.com/demos/1.0/docs/forms/forms-sample.html

Related

How to reload a page and keep the .load method Jquery

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?

forms on lightboxes

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/

Codeigniter submit form written in plain HTML

I'm playing for about 2 days now and can't make this out. I'm working in codeigniter 2.1.0. and I want to submit a form that is written in HTML. I don't want to use the CI form helper.
The reason is because I'm dynamically with JavaScript adding things in the form. When a user clicks an item then it's added to the form. Now when the user clicks the submit button all the items I added should be sent in a POST request, but my POST is totally empty.
Now I noticed that the POST only gets sent when I use form_input() from the CI form_helper.
Is it possible to just submit a normal plain HTML form without using the form helper?
Is it possible to just submit a normal plain HTML form without using the form helper?
Yes. The actual submit is totally independent to CI, just ensure you use the correct action URI of the form so that the correct controller action is called by the form submit post (I assume your form method is post) request.
You do not need to use the CI form_helper for the submit button. If you mock a form with these you will see that those just generate plain HTML and do nothing magically.

How to submit part of inputs from a form to another domain?

When user create a post, inside the post form, I want to provide a button. When user click the button, it will launch an iframe and submit some of the inputs of the post form. When nested form is not valid, how can I submit those inputs to the other website?
Two methods, Javascript, and PHP
Javascript:
You can use jQuery Post to do this by javascript.
Basic steps:
Use an "onsubmit" handler for the form
In the function for handling the submit, build a data array with data you want to submit and send to the second form.
Either return true (to allow the programmed submit to continue) or build a secondary submit if required.
This one allows you to build the validation you refer to client-side (i.e. in the submit handler).
PHP
Receive the data in the php form, then use CURL in the receiving PHP script to pass data as needed to the second form.

PHP & AJAX - Submit form doesn't work because of 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.

Categories