AJITH VD

AJITH VD

  • NA
  • 19
  • 449

javascript not working

Dec 26 2018 1:14 AM

 whats wrong in this code?

i double checked script src="~/Scripts/jquery.signalR-2.4.0.min.js"></script> (location),
java script in not working here.using visual studio 2017 
 
help me 
<html>
<head>
@section scripts {
<!--Script references. -->
<!--The jQuery library is required and is referenced by default in _Layout.cshtml. -->
<!--Reference the SignalR library. -->
<script src="~/Scripts/jquery.signalR-2.4.0.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="~/signalr/hubs"></script>
<!--SignalR script to update the chat page and send messages.-->
<script>
alert("scs");
$(function () {
// Reference the auto-generated proxy for the hub.
var chat = $.connection.chatHub;
// Create a function that the hub can call back to display messages.
chat.client.addNewMessageToPage = function (name, message) {
if (name == "Atir") {
// Add the message to the page.
$('#discussion').append("<p style='color:blue; text-align:left; !important;'><img = src='https://www.phplivesupport.com/pics/icons/avatars/public/avatar_7.png'>"
+ ' </strong> ' + htmlEncode(message) + '</p>');
}
else if (name != "Atir") {
// Add the message to the page.
$('#discussion').append("<p style='color:blue; text-align:right;'><img = src='https://www.phplivesupport.com/pics/icons/avatars/public/avatar_71.png'>"
+ ' </strong> ' + htmlEncode(message) + '</p>');
}
};
// Get the user name and store it to prepend to messages.
alert("scs");
$('#displayname').val(prompt('Enter your name:', ''));
// Set initial focus to message input box.
$('#message').focus();
// Start the connection.
$.connection.hub.start().done(function () {
$('#sendmessage').click(function () {
// Call the Send method on the hub.
chat.server.send($('#displayname').val(), $('#message').val());
// Clear text box and reset focus for next comment.
$('#message').val('').focus();
});
});
});
// This optional function html-encodes messages for display in the page.
function htmlEncode(value) {
var encodedValue = $('<div />').text(value).html();
return encodedValue;
}
</script>
}
<style>
div.panel-body {
overflow: scroll;
background: url('C:\Users\ajith\Pictures\yh.jpg');
}
</style>
</head>
<body>
<br />
<br />
<br />
<h2 style="text-align:center"> CHAT BOX </h2>
<br />
<br />
<br />
<div class="chat-panel panel panel-default">
<div class="panel-heading">
<h3 style="text-align:center"></h3>
<i class="fa fa-paper-plane fa-fw"></i>
</div>
<!-- /.panel-heading -->
<div class="panel-body" id="chat" style="height:250px;">
<input type="hidden" id="displayname" />
<p id="discussion"></p>
</div>
<!-- /.panel-body -->
<div class="panel-footer">
<div class="input-group">
<input id="message" type="text" name="message" class="form-control input-sm" placeholder="Type your message here..." />
<span class="input-group-btn">
<input type="button" class="btn btn-warning btn-sm" id="sendmessage" onblur="alert('File selected')" value="Send">
</span>
</div>
</div>
</div>
</body>
</html>

Answers (1)