I am having problem passing a javascript variable to php code.
The code that I am using for php is :
$image= $this->user_gallerymodel->viewAlbumImage();
I just need to pass javascript variable as a parameter in model function.
I am having problem passing a javascript variable to php code.
The code that I am using for php is :
$image= $this->user_gallerymodel->viewAlbumImage();
I just need to pass javascript variable as a parameter in model function.
using location.href
you can call the controller .. this reloads the page
var jvVar="test";
window.location="controller/path/" + jvVar;
wihtout reloading you can use ajax to send the var..
var jvVar="test";
$.post("controller/path/test",{value:jvVar},function(data){
alert(data);
});
and in you contorller say test().. get it by post..
<?php
function test(){
$value=$this->input->post('value');
echo $value;
}
You could use an Ajax call where values contains the value you wish to send back.
$.ajax({
url: "test.php",
type: "post",
data: values,
success: function(){
alert("success");
$("#result").html('Value Saved');
},
error:function(){
alert("failure");
$("#result").html('there was an error while saving value');
}
});