0

I want add New Product without refresh the Page. So, I Use Bootstrap Model for to Add New Product.

If i use Form Tag model has been redirect same page. How to Avoid It. I am working in Laravel Project

$(document).ready(function() {    
 $("#add").click(function() {    
        $.ajax({
            type: 'post',
            url: $("#add").attr('data-url'),
            data: {
             '_token': '{{ csrf_token() }}',
            'form_data': $('#Form').serialize(),
            },
            success: function(data) {                   
                 $('#ledger_name').val('');
                 $('#openning_balance').val('0.00');
                 $('#ob_type').val('');
                 $('#under').val('');
                 $('#ledger_address').val('');                     
                 $("#newLedger .close").click();
                 alert("Data Inserted");
            },

         error: function(data)
            {
                var errors = '';
                for(datos in data.responseJSON){
                    errors += data.responseJSON[datos] + '<br>';
                }
                $('#response').show().html(errors); //this is my div with messages
            }

        });

    });

    });

1 Answer 1

1

Add this on your beginning of your ajax call. do you want to refresh a div without reloading page???

event.preventDefault();
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.