2

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/submits/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 
})

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

In your code on click function write var form_params = $(".ser_form").serialize() and then send this form_params in the ajax call.
I have this output in var_dump:bool(false) , i put as: $('#edit_icon').click(function(){$(".ser_form").serialize()...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.