I read on the web many things about creating form in jquery mobile and I didn't understand one thing. When I create a form and I would pass data through php, I hear jquery mobile serialize them and automatically pass over and if the form has been created using post method I can use them in an other page only using _POST array and nothing all. But I read also some people like it form with ajax use ajax to pass variable. So I didn't understand why use ajax?
The default for the jQuery Mobile framework is to submit forms via HTTP POST. Why? because then your web application has greater control over the UI when animating through pages, creating a smooth transition. Well, a better description can be found in the jqm docs here.
If you are looking to disable the default Ajax functionality, just append this to your form element:
data-ajax="false"
Hope this helps!
Related
So I'm trying to understand jQuery's .ajax function so that when I create my sites CMS I can update content on the backend asynchronously. I'm creating a simple form to start out. I pass the id of the database using php in the action href of the form. I pull the data from the form and convert it to json using the .serialize() jQuery function and then pass the action and the data into the .ajax function. On my the backend I use php to pull the $_POST and $_GET items and update the database accordingly. Everything works except that the site actually links to my backend php site... I just figure this out actually but I can post the answer for future references for people. Let me know if my answer is incorrect.
It looks like I was using type="submit" for the update input for the form. Because I was using action = "mybackendhref" in the form This caused it to link to the actually page that I wanted to use .ajax to push the data to instead. Changing to input type="button" caused everything to work smoothly.
*By "mybackendhref" I mean the actual site I want to push the data to using .ajax.
Ok,this is tricky.
I have a form which ask user to upload a file.
I am not submitting the form on submit button,I am doing it on click of an image enclosed in href="#"
reloading the page is to be avoided.(this is the most challenging part)
I have used prevent default on href click and then sended an ajax call to my php page.This does not work.
If I use a tag..it reloads.
If I dont use it,i cant send my file.
I can only use multipart form data when using form tag.
What do i do??
iframe,upclick.js..but i am totally unaware of these.
Just in case if you want to go through my code(note:not a working model,just wanted to keep the question clean):http://jsfiddle.net/feRx3/
Hope I am clear with my question.
A little embarrassing at 1200 rep,I fumble at form.Any help?IE7 support is must!!!
I have used jQuery form plugin. It uses ajax 2.0 if you are on a modern browser or falls back to an iFrame for old browsers.
You should not reinvent the wheel. There are plenty of libraries that does the job.
Try Plupload : http://www.plupload.com/
Is it possible to have a JSP/JSPX form to submit to a PHP file?
The PHP file will then be in charge of validation and database update. After that it will send a sort of response to the same JSP/JSPX form. Also this should be done in AJAX using jQuery.
How can I do that and what are the underlying concepts needed?
Thanks!
You don't need anything specific in your case. Just submit the form via Ajax using jQuery to the PHP page and process the result in JavaScript as well. All the code necessary for that will be client side in JavaScript and operate on the plain HTML generated by the JSP page. The only restriction/problem might be if these two pages run on different domains.
I'm trying to implement a search for my project , but i can't figure it out how to use ajax and get data to the view, can some one help me with this?
(this is my first project using codeignter and jquery)
regards,
Rangana
Here's a quick overview:
You need to create an input box (obviously).
On your js file, you give that input an event (keypress or anything you want) and when the event triggered you send an ajax post request to your controller method.
On your controller method you read the post request, then do a DB search, you return the result to your js by 'echoing' the DB search result using your preferred format (JSON, xml, etc).
You process the result on your js file using callback.
codeigniter and jquery are unbeatable
see if this can help ...
So I am using "load" functions of jQuery to use ajax on my pages.
Can anyone write a small snippet of code using jquery load (or any ajax function which you think is the best) ? What I do is make a form, onsubmit pass to js, further using GET pass values into the load function and return false; though this works I am sure this is not the best way. Also this does NOT work in Opera.
It sounds like what you're trying to do is submit a form to an existing server-side script using AJAX. If so, consider using the jQuery form plugin. It will let you very easily make an existing form submit via AJAX.
If that's not your goal, we'll need a lot more detail about what — specifically — you're trying to accomplish.