1

I use this jquery into a modal with a select. When user select an option, document_fetch.php is called and some extra field are showed to user.

I'm like to use same modal to EDIT data.

If I add

$("#class_id").val("2").change();

and I open a modal select value appear correctly.

There is a way to start ajax request by clicking the button for open modal, for example?

$(document).ready(function(){ 



    $('#class_id').change(function(){  
    
       var cnt_man_class_doc_id = $(this).val();
       var cnt_man_folder_id = <?php echo $cnt_man_folder_id; ?>;
       
       $.ajax({
            url:"document_fetch.php",  
            method:"POST",  
            data:{cnt_man_class_doc_id:cnt_man_class_doc_id,
                  cnt_man_folder_id:cnt_man_folder_id
                 }, 
            success:function(data){  
                 $('#show_product').html(data);  
                 
            }
       });
    });



 });

1 Answer 1

1
$("#class_id").val("1").change();
  
$("#YourButtonId").on("click", function(e) {
e.preventDefault();

var cnt_man_class_doc_id = $(this).val();
var cnt_man_folder_id = <?php echo $cnt_man_folder_id; ?>;
       
       $.ajax({
            url:"document_fetch.php",  
            method:"POST",  
            data:{cnt_man_class_doc_id:cnt_man_class_doc_id,
                  cnt_man_folder_id:cnt_man_folder_id
                 }, 
            success:function(data){  
                 $('#show_product').html(data);  
                 
            }
       });
       
});
Sign up to request clarification or add additional context in comments.

Comments

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.