Yes that would work, although you might disable the submit button right away in the click handler… AIUI the beforeSend callback should be used for modifying (or even cancelling) the actual request.
BTW you’re performing a lot of unnecessary DOM requests here; it would be much more efficient to store the jQuery objects in a variable once and then refer to those. Also note that you can chain jQuery methods:
$('#sbt').click(function (e) {
e.preventDefault()
var $this = $(this)
var url = $this.attr('data-url')
var msg = $('#msg').val()
var ser = $('#ser').val()
$this
.html('sending...')
.attr('disabled', true)
$.ajax({
url: url,
type: 'post',
data: {
message: msg,
numbers: ser
},
cache: false,
success: function (response) {
swal(response)
$this
.html('send')
.attr('disabled', false)
}
})
})