Welcome Guest, Not a member yet? Register   Sign In
Ajax doesnt pass get value ?
#11

[eluser]michal85[/eluser]
View file
Code:
$(document).ready(function()
    {
        $(".cat_type").change(function()
        {
            var cct = $("input[name=csrf_test_name]").val()
            var typeid = $(this).val();
            $.ajax
            ({
                type: "POST",
                url: "<?php echo base_url('advert/getcat_by_type/');?>",
                data: {'typid':typeid,'csrf_test_name':cct},
                cache: false,
                success: function(html)
                {
                    $(".category").html(html);
                },
              error: function(){      
                      alert('Błąd');
              }
            });
        });
    });

Controller
Code:
function getcat_by_type()
{
             echo json_encode($_POST);  
}

Firebug :
csrf_test_name 30c7b5f90a440af7e8563434229760ce
typid 1

Result -> [] (http://www.testcms.grpx.pl/pl/advert/add)
#12

[eluser]michal85[/eluser]
I forgot that I gave access to this page only to logged users, so You couldnt see what I mean.

Once again - http://www.testcms.grpx.pl/pl/advert/add
#13

[eluser]TheFuzzy0ne[/eluser]
Your Web site is sending a 301 header and redirecting from:

http://www.testcms.grpx.pl/advert/getcat_by_type

to:
http://www.testcms.grpx.pl/pl/advert/getcat_by_type

However, I don't think this is the problem. I suspect it's something extremely simple, because it doesn't even get as far as making the request to the server. It just throws an error immediately.
#14

[eluser]michal85[/eluser]
Thank very much for Your help.

Code:
$(document).ready(function()
    {
        $(".cat_type").change(function()
        {
            var cct = $("input[name=csrf_test_name]").val()
            var typeid = $(this).val();
            $.ajax
            ({
                type: "POST",
                url: "<?php echo base_url($this->config->item('language_abbr').'/advert/getcat_by_type');?>",
                data: {typid:typeid,csrf_test_name:cct},
                cache: false,
                success: function(html)
                {
                    $(".category").html(html);
                },
              error: function(){      
                      alert('Błąd');
              }
            });
        });
    });

And its finally works!




Theme © iAndrew 2016 - Forum software by © MyBB