Ajax调用不起作用 [英] Ajax call not working
本文介绍了Ajax调用不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从同一个项目中的html页面调用此方法'Get_myHours'。
它不起作用请帮助!!!
function show(){
$ .ajax({
type: 获取,
url: http:// localhost:51065 / Service1.svc / Get_myHours,
contentType: application / json; charset = utf-8,
dataType: json,
数据:{
loginIDtxt:loginIDtxt
},
成功: function (响应){
var Days = response.Days;
var FinalTime = response.FinalTime;
$(' #jsonData')。html(' ');
$(' #jsonData')。append(' < table>< tbody>< tr>< th>' +
' Days< / th>< th> FinalTime< / th>' +
' < / tr>< tr>< td>' + Days + ' < / td>< td>' + FinalTime +
' < span class =code-string>< / td>< / tr>< / tbody>< / table>');
},
错误: function (msg){
alert( 错误);
}
});
}
< div>
& lt; input id = loginIDtxt type = text />
& lt; button onclick = show()>输入& lt; /按钮>
< / div >
< div id = jsonData>
< / div >
< / PRE >
解决方案
.ajax({
type: GET,
url: < span class =code-string> http:// localhost:51065 / Service1.svc / Get_myHours,
contentType: < span class =code-string> application / json; charset = utf-8,
dataType: json,
数据:{
loginIDtxt:loginIDtxt
},
成功: function (回复){
var Days = response.Days;
var FinalTime = response.FinalTime;
(' #jsonData')。html(' ');
(' #jsonData') .append(' < table>< tbody>< tr>< th>' +
' Days< / th>< th> FinalTime< / th>' +
' < / tr>< tr>< td>' + Days + < span class =code-string>' < / td>< td>' + FinalTime +
' < / td>< / tr>< / tbody> ;< /表>'跨度>);
},
错误: function (msg){
alert( 错误);
}
});
}
< div>
& lt; input id = loginIDtxt type = text />
& lt; button onclick = show()>输入& lt; /按钮>
< / div >
< div id = jsonData>
< / div >
< / PRE > 跨度>
i am calling this method 'Get_myHours' from html page which is in the same project.
its not working please help !!!
function show() {
$.ajax({
type: "GET",
url: "http://localhost:51065/Service1.svc/Get_myHours",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: {
loginIDtxt: loginIDtxt
},
success: function (response) {
var Days = response.Days;
var FinalTime = response.FinalTime;
$('#jsonData').html('');
$('#jsonData').append('<table><tbody><tr><th>' +
'Days</th><th>FinalTime</th>' +
'</tr><tr><td>' + Days + '</td><td>' + FinalTime +
'</td></tr></tbody></table>');
},
error: function (msg) {
alert("error");
}
});
}
<div>
<input id="loginIDtxt" type="text" />
<button onclick="show()">Enter</button>
</div>
<div id="jsonData">
</div>
</PRE>
解决方案
.ajax({ type: "GET", url: "http://localhost:51065/Service1.svc/Get_myHours", contentType: "application/json; charset=utf-8", dataType: "json", data: { loginIDtxt: loginIDtxt }, success: function (response) { var Days = response.Days; var FinalTime = response.FinalTime;
('#jsonData').html('');
('#jsonData').append('<table><tbody><tr><th>' + 'Days</th><th>FinalTime</th>' + '</tr><tr><td>' + Days + '</td><td>' + FinalTime + '</td></tr></tbody></table>'); }, error: function (msg) { alert("error"); } }); } <div> <input id="loginIDtxt" type="text" /> <button onclick="show()">Enter</button> </div> <div id="jsonData"> </div> </PRE>
这篇关于Ajax调用不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文