Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6548945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:01:59+00:00 2026-05-25T12:01:59+00:00

I’ve got a issue here, i keep getting a error when i try to

  • 0

I’ve got a issue here, i keep getting a error when i try to post something with ajax (POST). I know it is the CSRF that gives me these problems and I’ve been tried back and forth trying to find a solution. However, i hope somebody here can help me out!

This is the error i keep getting (from google chrome inspector),

*Failed to load resource: the server responded with a status of 500 (Internal Server Error)
XHR finished loading: “http://localhost/woho/ajax/images”.
*

PHP (Controller)

class Ajax extends CI_Controller {

    function images() {

        echo 'Hello World';

    }

}

Javascript

var ID = $(".imageWrap:last").attr("id");
var baseurl = "http://localhost/woho/";
var doScroll = 1;
var cct = $.cookie('csrf_cookie_name');

if (location.href == baseurl) {
    $(window).scroll(function(){
        if ($(window).scrollTop() > $('body').height() / 2) {
            if(doScroll == 1) {                   
                $.post(baseurl + 'ajax/images',{'id' : ID, 'csrf_token_name': cct}, function(data) {
                    alert(data);
                    $("#wrapper_content").append(data);
                    ID++;
                });
            }
        }
    });
}

my CCT var from javascript gives me the correct token or “hash” but when the javascript sends the ajax request codeigniter returns an error like,

An Error Was Encountered The action you have requested is
not allowed.

How can i fix this? do i need to validate the CSRF Token or something in my controller?

I’m using Codeigniter 2.0.3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:01:59+00:00Added an answer on May 25, 2026 at 12:01 pm

    Try (javascript):

    var ID = $(".imageWrap:last").attr("id");
    var baseurl = "http://localhost/woho/";
    var doScroll = 1;
    var cct = $.cookie("<?php echo $this->config->item("csrf_cookie_name"); ?>");
    
    if (location.href == baseurl) {
        $(window).scroll(function(){
            if ($(window).scrollTop() > $('body').height() / 2) {
                if(doScroll == 1) {                   
                    $.post(baseurl + 'ajax/images',{'id':ID,'<?php echo $this->security->get_csrf_token_name(); ?>': cct}, function(data) {
                        alert(data);
                        $("#wrapper_content").append(data);
                        ID++;
                    });
                }
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an issue that was wondering if could be solved in a particular
I've got two ListBox'es that are databound to the same BindingList. The issue is
I’ve got an issue with loading a particular X509 certificate within an ASP.NET application
I've got two sizing issue regarding a Window I've got. The basic layout is
This issue came up when I got different records counts for what I thought
Got a class that serializes into xml with XMLEncoder nicely with all the variables
Got myself in a bit of a pickle here ... working on a CMS
I'm having some inheritance issues as I've got a group of inter-related abstract classes
Got a bluescreen in windows while cloning a mercurial repository. After reboot, I now
got a new blog at wordpress few days ago ( http://ghads.wordpress.com ) and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.