小编Den*_*nis的帖子

Codeigniter中的JQuery Ajax POST

我已经用POST方法搜索了很多教程,并在这里看到了回答的问题,但我的POST仍然不起作用......我想我应该在这里发布,如果你们看到我不知道的东西!

我的js - messages.js:

$(document).ready(function(){   

    $("#send").click(function()
    {       
     $.ajax({
         type: "POST",
         url: base_url + "chat/post_action", 
         data: {textbox: $("#textbox").val()},
         dataType: "text",  
         cache:false,
         success: 
              function(data){
                alert(data);  //as a debugging message.
              }

     return false;
 });
 });
Run Code Online (Sandbox Code Playgroud)

我的观点 - chat.php:

<?php $this->load->js(base_url().'themes/chat/js/messages.js');?> //i use mainframe framework which loading script this way is valid



<form method="post">
    <input id="textbox" type="text" name="textbox">
    <input id="send" type="submit" name="send" value="Send">
</form>
Run Code Online (Sandbox Code Playgroud)

最后我的控制器 - chat.php

//more functions here

function post_action()
{   
    if($_POST['textbox'] == "")
    {
        $message = "You can't send empty …
Run Code Online (Sandbox Code Playgroud)

jquery post codeigniter

12
推荐指数
2
解决办法
9万
查看次数

标签 统计

codeigniter ×1

jquery ×1

post ×1