Load mysqli php data via ajax call

后端 未结 2 1830
野的像风
野的像风 2020-12-20 06:55

What I\'m trying to do is calling some database data via ajax and php. But the ajax call doesn\'t work, and I can\'t find out a solution on the web.

So here is my co

2条回答
  •  隐瞒了意图╮
    2020-12-20 07:35

    Your variable css has no value. You wanted to use the string 'css'. Maybe you want to be able to load other categories, too. So change your ajaxCall function to

    function ajaxCall(category)
    {
        $.ajax({
            url: 'test.php',
            type: "GET",
            data: {cat: category},
            dataType: 'json',    
            success: function(rows) {
               alert(rows);
            },
            error: function() {
               alert("An error occurred.");
            }
        });
    }
    

    and call it using

    ajaxCall('css');
    

提交回复
热议问题