Codeguy007
Codeguy007

Reputation: 891

Jquery script not executing as expected

I have a simple jquery ajax script that sends value to a web service for processing but for some reason the jquery doesn't run at all.

<!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>

Here's the 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"); });
    });
});

Here's the example I am testing with http://www.2100computerlane.net/workingproject/index.html

Upvotes: 0

Views: 43

Answers (2)

atredis
atredis

Reputation: 382

When I clicked link I got javascript error "Uncaught SyntaxError: Unexpected identifier ".

Upvotes: 0

TheZ
TheZ

Reputation: 3732

$(document)ready(function(){ is missing a dot to indicate a function call:

$(document).ready(function(){

Upvotes: 5

Related Questions