Welcome Guest, Not a member yet? Register   Sign In
ajax, jquery problem
#8

[eluser]GrahamDj28[/eluser]
When using csrf protection you must pass the csrf token along with the rest of your post data.

To get the csrf token in your ajax you can add this function as a global function to your JS

Code:
function getCookie(cookie_name) {
    var i,x,y,ARRcookies=[removed].split(";");
    for (i=0;i<ARRcookies.length;i++) {
        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
        x=x.replace(/^\s+|\s+$/g,"");
        if (x==cookie_name) {
            return unescape(y);
        }
    }
}

Just call the function with the name of your csrf cookie to get the token.


Messages In This Thread
ajax, jquery problem - by El Forum - 12-18-2012, 09:01 AM
ajax, jquery problem - by El Forum - 12-19-2012, 03:32 AM
ajax, jquery problem - by El Forum - 12-19-2012, 05:20 AM
ajax, jquery problem - by El Forum - 12-28-2012, 12:54 PM
ajax, jquery problem - by El Forum - 12-28-2012, 02:04 PM
ajax, jquery problem - by El Forum - 12-28-2012, 02:12 PM
ajax, jquery problem - by El Forum - 12-28-2012, 02:20 PM
ajax, jquery problem - by El Forum - 12-30-2012, 05:54 AM
ajax, jquery problem - by El Forum - 12-30-2012, 07:33 AM
ajax, jquery problem - by El Forum - 12-30-2012, 08:28 AM
ajax, jquery problem - by El Forum - 12-30-2012, 09:15 AM
ajax, jquery problem - by El Forum - 12-30-2012, 11:46 AM
ajax, jquery problem - by El Forum - 12-30-2012, 03:09 PM
ajax, jquery problem - by El Forum - 12-31-2012, 03:44 AM
ajax, jquery problem - by El Forum - 12-31-2012, 03:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB