Jquery脚本未按预期执行

Cod*_*007 0 jquery

我有一个简单的jquery ajax脚本,它将值发送到Web服务进行处理但由于某种原因,jquery根本不运行.

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.8.2.js"></script>
<script type="text/javascript" src="update-cart.js"></script>
</head>
<body>
<div id='colors'>
<a href="3333">Add Color</a>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是jQuery

// to use surround anchor tags with div (id=colors). Set color or scheme id as href value. On click the item is posted to the web service.
// To do improve response handling from webservice.

$(document)ready(function(){
    $("#colors a").live("click", function() {
        alert("We get here");
        var item = $(this).attr( 'href' );
        var jqxhr = $.post("webservice.php", { action: "add", color: item }, function() {
            alert("success");
        })
        .error(function() { alert("error"); })
        .complete(function() { alert("complete"); });
    });
});
Run Code Online (Sandbox Code Playgroud)

这是我用http://www.2100computerlane.net/workingproject/index.html测试的例子

The*_*heZ 5

$(document)ready(function(){ 缺少一个点来表示函数调用:

$(document).ready(function(){
Run Code Online (Sandbox Code Playgroud)