I Want To Ask May I use Ajax to send data to multi pages phph
i have 2 buttons in an HTML from and i want each button to send data to different php pages using ajax from the same html page
Ya.. You can make this.. if the functionality is different, you need to give individual AJAX request for each page.. if the functionality is same, you can change the URL dynamically and send with the single AJAX request...
Related
What are the advantages of using jQuery Ajax to POST data to the backend?
Is it necessary to use jQuery Ajax to POST if your html and php are on the same page? (meaning it only reloads, not redirect, after being submitted traditionally).
Whether to use jQuery or vanilla JavaScript is your choice. Ajax is useful if you just want to send a small size of data to the server without downloading the entire page from the server.
Suppose you have a page with 1000s of lines of HTML and you need to submit a simple yes or no response to a question to the server. Now, if you just redirect to the same page, it will still download most of the HTML page again. Ajax will just send that bit of data you want to send to the server and get a response which you can use within the client side to make changes to the page.
Is it possible to update the value of a variable from another page using JavaScript?
or
Is it possible to do this using form on submit, just update the other page, but remain on the page on which the form is located?
I think what you are searching for is AJAX (Asynchronous JavaScript and XML) which performs a get or post action and waiting for the result of the server. This makes it possible to submit a form without jumping to the page.
Have a look at this
Or if you use JQuery this
You can simply send all the data to be updated via Ajax and simply get the response on the current page You are in.
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 have a php page with some functions to recieve POST data, with a page refresh, no AJAX.
Right now I have a form with hidden fields that contain my dynamic data that I send with JS like so: document.my_form.submit();
Is it possible to send the data without using a form?
Basically I want to send an array of URL's from a list with thumbnails, so my function loops over the list and pushes them in arrays.
2000 characters should be ok these days:
http://www.boutell.com/newfaq/misc/urllength.html
Nope, you can only POST data via AJAX or a form.
you can use get instead of post, but it sounds like the url will get pretty messy. if you aren't opposed to ajax, i would be happy to elaborate on the answer.
I basically have to do a update of a record. I have a set of controls like textbox, list box, radio button etc. Then i have a button on click of which i need to carry all the updated data into mysql database with a ajax request without page refresh.
I am using the php with codeigniter as my serverside code. On client side i am able to send the ajax request like
$(document).ready(function(){
$('#users_menu').click(
function(){
$('#tempdiv').load('http://localhost//web1/index.php/c1',null);
}
);
});
In the above code the request is placed to a server side php page where i am not able to read the values of the control values (values of textbox, listbox etc). Now this means i should be sending the list with the request. But i am not aware of how to send this request.
Please help me with some details of how to send the list of values or is it possible to read the vaules some how in the serverside php code. For your information i am using codeigniter with my php. Any kind of help is appreciated.
Thanks and Regards
VinodT.
You need to use jQuery .post() function and specify the data to send, see here jQuery.post
You will end up needing to do something similiar to this.
$.post("http://localhost//web1/index.php/c1", $("#testform").serialize());