开发者

jQuery function returns undefined ? why?

开发者 https://www.devze.com 2023-03-22 03:31 出处:网络
http://www.kupe.nl/badkamer3.html I can\'t get allong with this online code thingy, just wont make a code block .. )

http://www.kupe.nl/badkamer3.html

I can't get allong with this online code thingy, just wont make a code block .. )

the jQuery function loadingAjax() is undefined ? this action is called when all the radios are filled in. some part of this form is retreived using an another function.

If you want to take a test

select the "New York" model. and proceed filling the form.. and submitting the button

Please help,

Thanks

js code :

<script type="text/javascript">
$(document).ready(function(){

$("#ptmodel label").click(function() {

    var mainImage = $(this).attr("name");
    var targetRadio = $(this).attr("for");
        $("#main_image img").attr({ src: 'http://www.kupe.nl/media/privatetime/images/smaller/' + mainImage + '.jpg' });
    $("#" +targetRadio).attr("checked", "checked");


    var selected = mainImage;
    var selecteddataString = 'in_pt_model_label='+ selected;

    $.ajax({
    type: "POST",
    url: "badkamer_sets.php",
    data: selecteddataString,
    success: function(selected){
    $("#ptsize_check").html(selected);
        }

    });     
});

function loadingAjax(my_div){
        var size = $('input:radio[name=in_pt_artikel]:checked').val();
        var color = $('input:radio[name=in_pt_color]:checked').val();
        var model = $('input:radio[name=in_pt_model]:checked').val();

    开发者_运维技巧       if(model == '' || model == null){
        $('#ptmodel_check').html('<font color="red">Selecteer een Model a.u.b</font>');

        }
        if (size == '' || size == null){
         $('#ptsize_check').html('<font color="red">Selecteer een Opstelling a.u.b</font>');

        }
        if (color == '' || color == null){
         $('#ptcolor_check').html('<font color="red">Selecteer een Front a.u.b</font>');

        }
        else {

        var dataString = 'in_pt_model='+ model + '&in_pt_color=' + color + '&in_pt_artikel=' + size;
    //$("#"+div_id).html('<img src="ajax-loader.gif"> saving...');

        $('#pt_form').hide();
        $('#'+my_div).html('<img src="ajax-loader.gif"> Een moment geduld alstublieft...');


        $.ajax({
    type: "POST",
    url: "badkamer_submit.php",
    data: dataString,
    success: function(msg){
            window.location="http://www.box7shop.nl/" + msg +".html";
    }
});

    }
}
});


</script> 

( thnx everone for the responses )

I got my problem solved like this :

$(document).ready(function(){ 
$("#ptmodel label").click(function() {


    var mainImage = $(this).attr("name");
    var targetRadio = $(this).attr("for");
        $("#main_image img").attr({ src: 'http://www.kupe.nl/media/privatetime    /images/smaller/' + mainImage + '.jpg' });
    $("#" +targetRadio).attr("checked", "checked");

    var selected = mainImage;
    var selecteddataString = 'in_pt_model_label='+ selected;

    $.ajax({
    type: "POST",
    url: "badkamer_sets.php",
    data: selecteddataString,
    success: function(selected){
    $("#ptsize_check").html(selected)
    }

    });     
});

$("#submitimg").live("click", function() {

var size =  $('input:radio[name=in_pt_artikel]:checked').val();
var color = $('input:radio[name=in_pt_color]:checked').val();
var model = $('input:radio[name=in_pt_model]:checked').val();

if(model === '' || model === null){
        $('#ptmodel_check').html('<font color="red">Selecteer een Model a.u.b</font>');
    return false;
        }
        if (size === '' || size === null){
         $('#ptsize_check').html('<font color="red">Selecteer een Opstelling     a.u.b</font>');
    return false;
        }
        if (color === '' || color === null){
         $('#ptcolor_check').html('<font color="red">Selecteer een Front     a.u.b</font>');
        return false;
        }
        else {

        var dataString = 'in_pt_model='+ model + '&in_pt_color=' + color + '&in_pt_artikel=' + size;
    //$("#"+div_id).html('<img src="ajax-loader.gif"> saving...');

    $('#pt_form').hide();
    $('#myDiv').html('<img src="ajax-loader.gif"> Een moment geduld     alstublieft...');

        $.ajax({
    type: "POST",
    url: "badkamer_submit.php",
    data: dataString,
    success: function(msg){
            window.location='http://www.box7shop.nl/' + msg + '.html';

    }
    });
    }
});

});


It looks like you need to remove the last "});" before the end script tag in the head of the document.

Change:

    }
});



To:

    }


I used to have some trouble with IE when i tried to get attributes with $.attr() that are not valid html. I have never used the attribute "for" and dont know if there is any attribute like that, but if it is invalid that may be the cause.

Try to change it to rel="" instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消