English 中文(简体)
履历
原标题:Jquery post with codeigniter

我从言辞转向密码,但我正在竭力要求控制员从这里的一个支队站接手。

我的亲身认为:

<a class="add_playlist" href="5657584"><img src="http://icons.iconarchive.com/icons/dryicons/simplistica/32/add-icon.png" alt="playlist"/></a>

页: 1

    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
    <script type= text/javascript >
    $( .add_playlist ).live( click , function() {

        alert( add );

        var video_url = $(this).attr( href );

            $.post("http://localhost/code/index.php/home/add_playlist", {video_url: video_url}, function(response) {
                console.log(response);

        });

    return false;

});

因此,我正试图做的是,把这一职责传给我家的控制员,叫他增加角色。 这里是我家中控制员的守则。

<?php if ( ! defined( BASEPATH )) exit( No direct script access allowed );

class Home extends CI_Controller {

    function add_playlist(){

        $this->load->model( home_model );

        // if HTTP POST is sent, add the data to database
        if($this->input->post( video_url )) {

        $video_url = $this->input->post( video_url );

        $this->home_model->add($video_url);

        } else {

        }
    }

}


    return false;

});
</script> 

And here is my home model

<?php

class home_model extends CI_Model {

    function add($data) {

        $this->db->insert( playlist , $data);

    }

}

So all i want it to do is add the href to the database can someone please scan this and helps

增 编

这是它 throw倒的错误。

add_playlistPOST http://localhost/code/index.php/home/add_playlist 500 (Internal Server Error)
问题回答

The code in your home controller has rogue javascript at the bottom:

    return false;

});
</script> 

?

不妨:

<?php if ( ! defined( BASEPATH )) exit( No direct script access allowed );

class Home extends CI_Controller {

    function add_playlist(){

        $this->load->model( home_model );

        // if HTTP POST is sent, add the data to database
        if($this->input->post( video_url )) {

        $video_url = $this->input->post( video_url );

        $this->home_model->add($video_url);

        } else {

        }
    }

}




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签