Reputation: 1967
I have had problems with this all day and can't find a solution. I need to create a function that gets data from a specific page. The id on the page needs to be passed on to the function. When I first try alert(value)
, it works, but the next time I insert it into .ajax url, it doesen't work. What can be the problem?
<script>
function func(value){
alert(value);
//WORKS FINE, alertbox with content "1" appears.
$.ajax(
{
type:'GET',
url:'<?=site_url("page/view/" + value);?>',
//DOES NOT WORK, when i enter "page/view/1" it works. When i enter "page/view/ + value" it does not work.
success: function(data){
alert(data);
}
}
);
}
$(document).ready(function() {});
</script>
Upvotes: 0
Views: 58
Reputation: 97717
You're trying to add the js variable in your php code, remove it from inside the php tags
url:'<?=site_url("page/view/");?>' + value,
Upvotes: 4