I'm making an application using codeigniter and I would like to know how I could take the information I retrieved from a select tag in a javascript file to take it to a variable in my model
I'm making an application using codeigniter and I would like to know how I could take the information I retrieved from a select tag in a javascript file to take it to a variable in my model
You need to make a request AJAX against a path set by you on the PHP CodeIgniter server sending you the data you need and receiving a response (usually in JSON format) of whether or not your request went to the server with the response data.
Here is an example of a simple AJAX request:
var request = new XMLHttpRequest();
request.open('GET', '/my/url', true);
request.onreadystatechange = function() {
if (this.readyState === 4) {
if (this.status >= 200 && this.status < 400) {
// Success!
var resp = this.responseText;
} else {
// Error :(
}
}
};
request.send();
request = null;