简体   繁体   English

将发布数据从Joomla发送到CodeIgniter

[英]Sending post data from Joomla to CodeIgniter

I have a system implemented in CodeIgniter, I am trying to send some data in a text area of Rsform component via POST to the url referring to my CodeIgniter system, I have tried usign AJAX request to send the post data using the following code 我有一个在CodeIgniter中实现的系统,我正在尝试通过POST将Rsform组件的文本区域中的一些数据发送到引用我的CodeIgniter系统的url,我尝试了使用以下代码发送有用的AJAX请求以发送该帖子数据

<script>
alert("jsc");
  var data;
  data='test from joomla!';
      $.ajax({
                type: "POST",
                url : 'http://localhost/cii/index.php/login/getNews/',
                data: {news:data},
                cache: false,

                success: function(html){
                alert(html);
                }
            });

getNews controller: getNews控制器:

function getNews() {
  //print_r($this->session->userdata);
  header('Access-Control-Allow-Origin: *');
  echo "news is ".$news=$_POST['news'];
  $data = array ( 'username' => "null", 'is_logged_in' => false, 'news'=>$news);
  $this->session->set_userdata($data); //var_dump($_POST); //               
  print_r($this->session->userdata); session_start(); echo session_id(); 
} 

but it failed, is there any other options ? 但是失败了,还有其他选择吗?

Use something like Firebug in mozilla firefox to observe what data is being posted to the app to check if your ajax call is working. 在mozilla firefox中使用诸如Firebug之类的工具观察正在将哪些数据发布到应用程序,以检查您的ajax调用是否正常。

Then in your codeigniter controller method, simply put this code to see if the data is getting to it. 然后,在您的codeigniter控制器方法中,只需将这段代码放入数据中即可查看。

function getNews()
{  
    foreach($_POST as $key => $val)  
    {  
        $options[$key] = $this->input->post($key);  
    }  

    var_dump($options);      
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM