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

  • SEARCH
  • Home
  • 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 7760031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:46:35+00:00 2026-06-01T13:46:35+00:00

i have a small problem here which i cannot fix,This post goes through but

  • 0

i have a small problem here which i cannot fix,This post goes through but the response returns a “500 internal server error”

who to fix it?

after search in CI forum i found this this link codeigniter-csrf-protection-with-ajax but i cant solve by it.can any one help me?

  • 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-06-01T13:46:36+00:00Added an answer on June 1, 2026 at 1:46 pm

    You should include the csrf key in your AJAX POST request to get the action to work.

    However, you’re only GETTING data, so using method:'get' instead of method:'post' should do the trick and make your request work.

    See this question for a wonderful discussion on when to use POST and when to use GET

    If you are, indeed, planning on POSTing data to the server, and it complains about the lack of the CSRF key, there are two ways to add it to the request:

    • use a plugin to allow prototype to extract the data from the csrf cookie that’s being set by codeigniter; this might be more elegant, but would add a little more to your total scripts; here’s a post with more detail on how to access cookies in prototype http://codeinthehole.com/writing/javascript-cookie-objects-using-prototype-and-json/

    • if you’re sending this request from an existing form, it should have a hidden input field containing the key, which you would be able to simply access with something like var csrf = $("input[name=csrf_key]").val(); (This is jQuery syntax, but I’m sure the prototype version isn’t too far away).
      If there isn’t a form in that page, just write an echo form_open(); form_close(); somewhere to make sure the hidden field gets printed out by CI.

    Finally, make sure you send that value alongside the POST request, to make sure you’re cool guy who doesn’t want to hackz0r the server. You should add this parameter to the ajax request in JS:

    parameters: {'csrf_key' : csrf}
    

    Where csrf is the variable in which you fetched the key (from the cookie or from the hidden input). Make sure the names are alright! If you’re fetching the cookie, make sure the cookie name coincides with the one set in config/config.php. Same goes for the input token!

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem, looked here & other forums, but could not find
So here is our problem: We have a small team of developers with their
Here's the problem -- I have a few thousand small text snippets, anywhere from
So here I believe I have a small buffer overflow problem I found when
I have a small problem that I cannot seem to wrap my head around
Usless Background Info Hello, all. This is my first post here, but I often
i shall state my problem here.. I have an index.html page which has a
i am having a small problem here. The table which dbml (LinqToSql designer) is
I have a small problem, which might me a stupid mistake on my side.
have small problem, and would very much appreciate help :) I should convert byte

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.