-1
我想将名称的值放在我的div标签中的Employee对象中,他的id是#taarget
。每当我在我的按钮,点击他的ID是#driver
Ajax请求调用json文件
这里我jQuery代码
$(document).ready(function() {
$("#driver").click(function() {
$.ajax(ajaxoptions);
// Ajax request sucess--
var successpage = function (resp) {
$("#target").html(resp.Employee[0].Name);
};
// Ajax request fail--
var failurerror = function (req, status, err) {
console.log('something went wrong', status, err);
};
// create a obect to make ajax request--
var ajaxoptions = {
url: "EmpDetails.json",
dataType: "json",
contentType: "application/json";
success: successpage,
error: failurerror
};
});
});
这里我的JSON文件.. EmpDeails.json
{
"Employee":
[
{
"Name": "Amit",
"Designation": "Trainee",
"Area": "Development"
},
{
"Name":"Rahul",
"Designation": "Developer"
"Area":"Designing"
},
{
"Name":"Sachin",
"Designation": "M.D"
"Area":"Management"
}
]
}
嘿M在jQuery的新..我的代码没有任何人可以帮助我使我的代码可运行..它将不胜感激..
OK先生,然后告诉我,我应该使用什么样的代码..如果u能帮助给我progaram代码..这将是对我非常有帮助。至于马初学者jQuery中第二阿贾克斯 – Ammi
@Ammi:完成。你在正确的轨道上。我不知道你为什么认为你应该把电话放在最前面,但除此之外你不远处...... :-) –
Sry它是我的错误....我用你的代码,但仍然是它的代码不工作的先生 – Ammi