Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- $('#form_discount').submit(function () {
- // show that something is loading
- $('#response').html("<b>Loading response...</b>");
- /*
- * 'post_receiver.php' - where you will pass the form data
- * $(this).serialize() - to easily read form data
- * function(data){... - data contains the response from post_receiver.php
- */
- $.ajax({
- <?php $request_ajax = URL . 'application/models/dashboard/Mov/Services/ServicesAjax.php'; ?>
- type: 'POST',
- dataType: "json",
- url: '<?= $request_ajax; ?>',
- data: $(this).serialize()
- })
- .done(function (data) {
- $('#myModal').modal('toggle');
- if (JSON.stringify(data['erro']) == 'true') {
- alert('ERROR ' + JSON.stringify(data['msg']));
- return false;
- } else {
- // show the response
- $('#response').html(JSON.stringify(data['msg']));
- }
- })
- .fail(function (data) {
- // just in case posting your form failed
- alert("Posting failed. \n Error :" + JSON.stringify(data['msg']));
- });
- // to prevent refreshing the whole page page
- return false;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement