tags:

views:

98

answers:

4

Where is problem: I got error: missing } after function body

(function($) { 
    $(document).ready( function() { 
        $("div.area_map").click( function () {
        alert('clicked'); 
        $('img.hoverswap', this).css({ 
            position:"absolute",
            left:"0px",
            top:"0px",
            width: "120",
            height: "52",
            zIndex: "9999"}).attr("src","default/citymap/D5.png");
            $.get("save.php", {id: 1, action: all}, function(result) {
                $("#results").html(result);
            }); 
        }); 
    }) ( jQuery ); 
A: 

You forgot to close the

$("div.area_map").click( function () {

so add another });

Tim
Now I have Error: jQuery is not defined
Nation
A: 

try this:

  $(document).ready( function() {
    $("div.area_map").click( function () {
        alert('clicked');
     $('img.hoverswap', this).css({
        position:"absolute",
        left:"0px",
        top:"0px",
        width: "120",
        height: "52",
        zIndex: "9999"}).attr("src","default/citymap/D5.png");
        $.get("save.php", {id: 1, action: all}, function(result) {
            $("#results").html(result);
        });
    });

    });
bhu1st
Its not working :(
Nation
great @Reigel solved this.
bhu1st
A: 

is it just me or you have forgotten to close the ready handler function?

(function($) { 
    $(document).ready( function() { 
        $("div.area_map").click( function () {
        alert('clicked'); 
        $('img.hoverswap', this).css({ 
            position:"absolute",
            left:"0px",
            top:"0px",
            width: "120",
            height: "52",
            zIndex: "9999"}).attr("src","default/citymap/D5.png");
            $.get("save.php", {id: 1, action: all}, function(result) {
                $("#results").html(result);
            }); 
        });
    }); // <<--- missing here.
}) ( jQuery ); 
Reigel
I closed handler but the same error: jQuery is not defined
Nation
**jQuery** not defined? you have forgotten to include jQuery.js?
Reigel
Doh! Yes, You was correct :) Tnx :)
Nation
you're welcome ^_^
Reigel
A: 

Try this :)

$(document).ready(function() { 
    $("div.area_map").click( function () {
        alert('clicked'); 
        $('img.hoverswap', this).css({ 
            position  : "absolute",
            left      : "0px",
            top       : "0px",
            width     : "120",
            height    : "52",
            zIndex    : "9999"
        }).attr("src","default/citymap/D5.png");
        $.get("save.php", {id: 1, action: all}, function(result) {
            $("#results").html(result);
        });
    });
});
Fred Bergman