Simple Ajax/Codeigniter request

前端 未结 8 781
無奈伤痛
無奈伤痛 2021-01-25 15:43

I\'m having some issues with ajax and codeigniter. I\'ve already posted another question (link to question) and I thought I solved it, but I did not so I`m asking someone to wri

8条回答
  •  生来不讨喜
    2021-01-25 16:01

    In your ajax, don't use external link for your JS just use internal.

    Make sure that you set your $config['base_url'] = http://localhost/test/ in config.php

    function increase(){
        var number = parseInt($('#number').html()) + 1;
        $.ajax({
            type: 'POST',
            url: 'welcome/increase',
            data: { increase:number },
            success:function(response){
               $('#number').html(response);
            }
       });
    
    }
    

提交回复
热议问题