开发者

send form data using jQuery

How can send data this input for php code without use button:submit(with use of tag <a href=""></a>) as that after it go to href and put row of $query in html code for update?

(i mean, after select checkbox and click on link in tag send value with jquery code to php code and go to link tag a for update)(i dont want to use action in tag form because i use from several url for action) How fix it?

HTML:

<a href="<?= base_url()?>submits/guide_update" class="guide_update" id="edit_icon"></a>
<form class="ser_form" method="post">
    <input type="checkbox" name="checked[]" value="2">
</form>

PHP:

function guide_update(){
$update = $this -> input -> post('checked');
var_dump($update);
if (is_array($update) && count($update) > 0) {
    foreach($update as $val){
        $data['query'] = $this->db->get_where('guide', array('id' => $val))->row();
    }
    $this -> load -> view('admin/su开发者_C百科bmits/guide_update', $data);
}
}

jQuery:

$('#edit_icon').click(function(){
    var result = true;
        var size_check = $(':checkbox:checked').size();
        //alert(size_check);
        if(size_check > 1){
            $('#message').hide().fadeIn('slow').html('<div id="error_text" style="background-color: #ffffd9; border: 1px solid #d2d200;">You're allowed to edit a row.<div>');
            $('#error_text').delay(7000).fadeOut('slow');
            result = false;
        }if(size_check == 0){
            //alert('no')
            $('#message').hide().fadeIn('slow').html('<div id="error_text" style="background-color: #ffffd9; border: 1px solid #d2d200;">You did not select any row for editing.<div>');
            $('#error_text').delay(7000).fadeOut('slow');
            result = false;
        }
    return result 
})


Use the JQuery.serialize function to serialize form data, which you can then send to the server using AJAX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜