سلام من یه صفحۀ مکالمه دارم که با جاوا اسکریپت پیاده سازی شده
همه چیزاش پر میشه فقط میخوام ارسال بشه به اکشن
این دکمۀ ارسال
<div class="col-sm-4 chat-send">
<button type="submit" class="btn btn-info btn-block waves-effect waves-light">ارسال </button>
</div>
این کدای جاوا اسکریپت
<script>
!function ($) {
"use strict";
var ChatApp = function () {
this.$body = $("body"),
this.$chatInput = $('.chat-input'),
this.$chatList = $('.conversation-list'),
this.$chatSendBtn = $('.chat-send .btn')
debugger
};
//saves chat entry - You should send ajax call to server in order to save chat enrty
ChatApp.prototype.save = function () {
var chatText = this.$chatInput.val();
var chatTime = moment().format("h:mm");
if (chatText == "") {
sweetAlert("Oops...", "You forgot to enter your chat message", "error");
this.$chatInput.focus();
} else {
$('<li class="clearfix"><div class="chat-avatar"><img src="images/avatar-1.jpg" alt="male"><i>' + chatTime + '</i></div><div class="conversation-text"><div class="ctext-wrap"><i>John Deo</i><p>' + chatText + '</p></div></div></li>').appendTo('.conversation-list');
this.$chatInput.val('');
this.$chatInput.focus();
this.$chatList.scrollTo('100%', '100%', {
easing: 'swing'
});
}
},
function sendData() {
debugger
//here is a sample list
var list = [];
var user1 = {};
user1.Id = 1;
user1.Name = "u1";
list.push(user1);
var user2 = {};
user2.Id = 2;
user2.Name = "u2";
list.push(user2);
$.ajax({
type: "POST",
url: '/Dashbaord/',
contentType: "application/json",
data: JSON.stringify(list),
}).done(function (data) {
console.log(data);
//the data is you want
});
}
ChatApp.prototype.init = function () {
var $this = this;
//binding keypress event on chat input box - on enter we are adding the chat into chat list -
$this.$chatInput.keypress(function (ev) {
var p = ev.which;
if (p == 13) {
$this.save();
return false;
}
});
//binding send button click
$this.$chatSendBtn.click(function (ev) {
$this.save();
return false;
});
},
//init ChatApp
$.ChatApp = new ChatApp, $.ChatApp.Constructor = ChatApp
}(window.jQuery),
//initializing main application module
function ($) {
"use strict";
$.ChatApp.init();
}(window.jQuery);
</script>خیلی ممنون از همکاری شما
سلام دوست من وقت بخیر
دوست من اطلاعات رو به صورت ajax میخواین بفرستین یا نه به صورت عادی؟