Javascript doesn't load PHP function in codeigniter, but does in pure PHP environment -


i have file.html tries call neg.php when image clicked (there many <p class="bagi">.

<p class ="bagi">                <a href="try.html" onclick="return false;">                                <img src="images/neg.png" title ="rate negative" onclick="negative(this);">        try try try try try     </a> </p> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript">     function negative(obj) {        var url = obj.parentnode.valueof('href');        var name = obj.parentnode.innertext;        alert(url);        $("#quote p").load("neg.php?url="+ url + "&name=" + name);     } </script>  <div id="quote"><p></p></div> 

the neg.php, located in same folder code above, , write text file subfolder cat/nonstatistics, this:

<?php  header("cache-control: no-cache"); $url = $_get["url"]; $name = $_get["name"];  $file = 'cat/nonstatistics/' . $name . '.txt'; if (!file_exists($file)) {     include_once 'classifier/classifier.php';     include_once 'classifier/trainer.php';      $current = file_get_contents($url);     $current2 = strip_tags($current);      $tr = new trainer();//i use php text classifier in     $arr = array('statistika', 'nonstatistika');     $tr->makecategory($arr);     $cl = new classifier();     $text = $current2;      $result = $cl->classifytext($text);     if ($result == 'nonstatistika') {         file_put_contents($file, $current2);         echo "rated negative, response!";     } else {         echo "rating failed";     } } else {     echo "nice.."; } ?> 

they worked fine, how wanted. when transferred code codeigniter framework, in put controller has views file.html, found not working, function stopped @ alert(url). have done <script type="text/javascript" src="<?php echo base_url() ?>js/jquery.js"></script> call jquery file.

i did this:

$("#quote p").load(base_url()+"views/load_hasil_cari/neg.php?url=" + url + "&name=" + name); 

and this:

$file = base_url .'views/load_hasil_cari/cat/nonstatistics/' . $name . '.txt'; 

none of them worked. clicked image , did alert(url).

what did not do? thanks..

edited: controller file:

<?php  if (!defined('basepath'))     exit('no direct script access allowed');  class retrain extends ci_controller {  public function retrain() {     parent::__construct(); }  public function index() {     $this->load->model('home_model');     $data = $this->home_model->general();     $data['file']=base_url().'application/views/load_hasil_cari/neg.php';             $this->load->view('load_hasil_cari/retrain_view', $data); }  } 

add neg.php in views folder , try change line

$("#quote p").load("neg.php?url="+ url + "&name=" + name); 

add in controller

$data['file']=base_url().'application/views/search/cat/nonstatistics/neg.php'; 

and in view change neg.php

<?php echo $file;?> 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -