Files
Web_IoTBase_Sever_Prod/TestWebAPI/Views/Index/Index.cshtml

77 lines
1.8 KiB
Plaintext
Raw Normal View History

2025-12-11 14:04:39 +08:00
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
<link href="~/css/bulma.css" rel="stylesheet" />
<link href="~/css/bulma.min.css" rel="stylesheet" />
<script src="~/js/jquery.min.js"></script>
<script>
$(function()
{
$("#btnsend").click(function()
{
let cmdtype=$("#txtdata").val();
let id=$("#idcmd").val();
let data=$("#txtdata").val();
console.log(data)
let aaa= {
Cmd: "tcp_send_data_clientid",
Parameterlist: {
"device_clientid": id,
"command_word":cmdtype,
"data":data
}
};
let YUI= JSON.stringify(aaa);
$.ajax({
url: 'http://localhost:5116/api/sockettcp/send_data_to_targetnew',
type: 'Post',
//contentType: 'application/x-www-form-urlencoded',
contentType: 'application/json',
data: JSON.stringify(aaa),
success: function(response) {
console.log(response);
},
error: function(xhr, status, error) {
console.log(error);
},
beforeSend: function(xhr) {
console.log('Sending request...');
},
complete: function(xhr, status) {
console.log('Request completed.');
}
});
});
});
</script>
<div class="field">
<label class="label">设备CID</label>
<div class="control">
<input id="txtid" class="input is-primary"
type="text"
placeholder="Primary input" />
</div>
</div>
<div class="field">
<label class="label">命令字:</label>
<div class="control">
<input id="idcmd" class="input is-primary"
type="text"
placeholder="Primary input" />
</div>
</div>
<div class="field">
<label class="label">数据:</label>
<div class="control">
<textarea id="txtdata" class="textarea"
placeholder="10 lines of textarea"
rows="10"></textarea>
</div>
</div>
<button id="btnsend" class="button is-link">发送</button>
@{
}