最近弄些关于网页的事情,涉及到javascript,有些不懂,帮忙解释一下,可以吗?function GetChilds(parentDdlId, ddlKeyConfig, ddlName, key, childIds)
{
var parentId = $("#" + parentDdlId).val();
if (parentId != "") {
var wrapper = $("#" + ddlName + "Wrapper");
wrapper.html("<img src='/Content/images/loading.gif' />");
var url = "/Ddl/" + ddlKeyConfig + "/" + parentId + "/" + ddlName + "/" + key;
if (childIds != null && childIds != "") {
url += "/" + childIds;
}
nsDebug.addMsgLine(url);
$.get(url, function (result) { wrapper.html(result); }, "text");
}
else {
ClearChilds(ddlName);
}
}
{
var parentId = $("#" + parentDdlId).val();
if (parentId != "") {
var wrapper = $("#" + ddlName + "Wrapper");
wrapper.html("<img src='/Content/images/loading.gif' />");
var url = "/Ddl/" + ddlKeyConfig + "/" + parentId + "/" + ddlName + "/" + key;
if (childIds != null && childIds != "") {
url += "/" + childIds;
}
nsDebug.addMsgLine(url);
$.get(url, function (result) { wrapper.html(result); }, "text");
}
else {
ClearChilds(ddlName);
}
}
如$("#" + parentDdlId).val()等同于document.getElementById(parentDdlId).value
建议学习jquery,个人觉得搞开发jquery是必备的知识
$.get(url, function (result) { wrapper.html(result); }, "text");
这个是什么用法啊,这句话有些看不懂了
能够解释一下大概这句话是什么意思吗?
jQuery.get(url,[data],[callback])
通过远程 HTTP GET 请求载入信息。
这是一个简单的 GET 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。--------------------------------------------------------------------------------Load a remote page using an HTTP GET request.
This is an easy way to send a simple GET request to a server without having to use the more complex $.ajax function. It allows a single callback function to be specified that will be executed when the request is complete (and only if the response has a successful response code). If you need to have both error and success callbacks, you may want to use $.ajax.
返回值
XMLHttpRequest参数
url (String) : 待载入页面的URL地址data (Map) : (可选) 待发送 Key/value 参数。callback (Function) : (可选) 载入成功时回调函数。示例
请求 test.php 网页,忽略返回值。 jQuery 代码:$.get("test.php");
--------------------------------------------------------------------------------请求 test.php 网页,传送2个参数,忽略返回值。 jQuery 代码:$.get("test.php", { name: "John", time: "2pm" } );
--------------------------------------------------------------------------------显示 test.php 返回值(HTML 或 XML,取决于返回值)。 jQuery 代码:$.get("test.php", function(data){
alert("Data Loaded: " + data);
});
--------------------------------------------------------------------------------显示 test.cgi 返回值(HTML 或 XML,取决于返回值),添加一组请求参数。 jQuery 代码:$.get("test.cgi", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});