Welcome Guest, Not a member yet? Register   Sign In
Ajax - CSRF
#1

[eluser]Ondrej[/eluser]
Hey there,

I've tried searching through this forum, but I wasn't able to find an answer that would work.

I'm working on back-office app and I would like to make a simple list of added news entries with a quick preview when you click on corresponding entry title. Here's the jQuery code:

Code:
//$(selector).hover(callbackIn, callbackOut);
$(".post_title").hover(
    function(){
        $(this).addClass("underlined");
    },
    function(){
        $(this).removeClass("underlined");
});

$(".post_title").click(function()
{
    var newsTitle = $(this).text();            
    var ajaxData = {
        title: newsTitle,
        csrf_token_name: $.cookie("csrf_cookie_name")
    };
            
    // $.post(url, data, callback, datatype)
    $.post(base_url + "admin/ajaxgateway", ajaxData, function(data){
               // Process data, do stuff
           }, "json");
        
        });

I can't get it to work with CSRF protection on, no matter which solution I try. If I switch it off, everything works flawlessly. Any ideas?

Thanks in advance.


Messages In This Thread
Ajax - CSRF - by El Forum - 07-05-2011, 01:00 PM
Ajax - CSRF - by El Forum - 07-05-2011, 04:35 PM
Ajax - CSRF - by El Forum - 07-06-2011, 01:53 AM
Ajax - CSRF - by El Forum - 07-06-2011, 05:10 AM
Ajax - CSRF - by El Forum - 07-06-2011, 05:41 AM
Ajax - CSRF - by El Forum - 07-06-2011, 06:19 AM
Ajax - CSRF - by El Forum - 07-06-2011, 07:04 AM
Ajax - CSRF - by El Forum - 07-30-2011, 12:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB