Skip to content

Instantly share code, notes, and snippets.

@alectoist
Created September 15, 2016 06:02
Show Gist options
  • Save alectoist/06fc6349ad4d7475d270351de36bfac2 to your computer and use it in GitHub Desktop.
Save alectoist/06fc6349ad4d7475d270351de36bfac2 to your computer and use it in GitHub Desktop.
someajax
$(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