[Answer]-Javascript, Ajax and Alert Not Working

1👍

I would guess its the ‘this.id’, try using on alert(this.id) before the $.get to see what its producing (or not).

I do something similar which should give you the idea

$(".productpicturedelete").on("click", "input[type=button]", function(event){
        var $buttonid = $(this).attr("id");
👤Foxy

0👍

Data source file name is missing in URL field:

$.get(“/models/”+this.id+”/viewmodelinfo/<data source file name>”, function(data) {..});

👤KSL

0👍

<script type="text/javascript">
    $(document).ready(function() {
        $('.cadlib').bind('click', function () {
            data_id = $(this).attr('id'); //add this

            $.get("/models/" + data_id + "/viewmodelinfo/", function(data) {
                alert ("yo");  // This line bellow doesn't execute
                if (data.fact_type=="T") {
                    guess_result="This fact is true! " + data.fact_note;
                } else {
                    alert ("yo");
                    guess_result="This fact is false! " + data.fact_note;
                }
                $('#result').replaceWith("guess_result");
            });
        });
    });
</script>

0👍

I am almost sure that this.id doesn’t exists in this context

$.get("/models/"+this.id+"/viewmodelinfo/", function(data)

What does this.id suppouse to be? Can you explain it please

Leave a comment