Welcome Guest, Not a member yet? Register   Sign In
Codeigniter, Base URL and Ajax
#2

[eluser]Bart v B[/eluser]
Where do you have your javascript defined?

Is it in the header of your view or an external .js?
In that way you have a problem, because you can not parse php in a javascript.

So, there are a few way's to solve this problem:

1. you put your script in your view.

Code:
<html>

<head>

<+script type="text/javascript">
httpObject.open("GET", "&lt;?php echo base_url();?&gt;home/getnews/", true);  <+/script>
&lt;/head


2. if it's an external .js then you must make an header to parse it to php..
something like this:

javascript.php

Code:
&lt;?php
header("Content-type: text/javascript");
?&gt;
httpObject.open("GET", "&lt;?php echo base_url()?&gt;home/getnews/", true);

and put offcourse this in your view page. Mind the extention. this is nou php Wink


Messages In This Thread
Codeigniter, Base URL and Ajax - by El Forum - 12-17-2010, 12:22 AM
Codeigniter, Base URL and Ajax - by El Forum - 12-17-2010, 01:09 AM
Codeigniter, Base URL and Ajax - by El Forum - 12-17-2010, 01:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB