无法拨打电话 [英] unable make a rest call
本文介绍了无法拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我想打个电话,并将输出重定向到HTML的文本区域.我正在附加代码,如果有,请更正我的错误,并在下面解释如何将电话的输出连接到文本区域中. firebug控制台,我成功了,但是我没有得到参考错误数据
hi all i want to make a rest call and redirect the output to a text area in HTML i am attaching the code please correct my mistake if any and please explain how to attach the output of the rest call into the text area in firebug console i get success but i get a reference error data is not defined
<script>
$(document).ready(function()
{
$.ajax({
url:"http://127.0.0.1:8300/pink",
method: "GET",
contentType: "application/json",
dataType : "json",
success : onSuccess().bind(this),
error : function() {
console.log("Failed node Data");
}
});
});
onSuccess = function()
{
console.log("success ");
document.writeln("pinkar" + data);
}
</script>
<body>
<input name="results" id="pods"type="radio">pink
<input name="results"id="testprojects"type="radio">testpink
<input name="results" id="results" type="radio">results
<div id ="output">
<div id="podarea"style="display: none;">
<textarea id="podar" rows="4" cols="50"> </textarea>
</div>
<div id="projectarea"style="display: none;">
<textarea id="proar"rows="4" cols="50"> project area</textarea>
</div>
<div id="resultarea"style="display: none;">
<textarea id="resar" rows="4" cols="50"> resultarea</textarea>
</div>
</body>
推荐答案
不要不必要地使其复杂化.
Don't make it complicated unnecesarily.
$(document).ready(function () {
$.ajax({
url: "http://127.0.0.1:8300/pods",
method: "GET",
contentType: "application/json",
dataType: "json",
success: function(data){
// But you mentioned that returned data type is JSON, make sure to parse it.
$("#podar").html(data);
},
error: function () {
console.log("Failed node Data");
}
});
});
但是您提到返回的数据类型是JSON,请确保对其进行解析或删除dataType:json
.
But you mentioned that returned data type is JSON, make sure to parse it or remove dataType:json
.
这篇关于无法拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文