Created
September 15, 2016 06:02
-
-
Save alectoist/06fc6349ad4d7475d270351de36bfac2 to your computer and use it in GitHub Desktop.
someajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('.sendPsc').on('click', function(e) { | |
e.preventDefault(); | |
var idTextArea = $(this).data('psc'); | |
var messageValue = $('#psc_'+idTextArea).val(); | |
$.ajax({ | |
url: window.location + '?rand=' + new Date().getTime(), | |
data: { | |
individual_product_message: message | |
}, | |
type: 'POST', | |
headers: { "cache-control": "no-cache" }, | |
success: function(json){ | |
if (json.status == "OK") { | |
$('.send-message-success').show(); | |
var messageDanger = $('.send-message-danger'); | |
messageDanger.html(''); | |
messageDanger.hide(); | |
} else { | |
$('.send-message-success').hide(); | |
var errorsContainer = $('.error-contents'); | |
$.each(json.errors, function(i, o) { | |
var errorMessage = '<p>' + o + '</p>'; | |
errorsContainer.append(errorMessage); | |
}); | |
$('.send-message-danger').show(); | |
} | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment