• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AJAX post returns 500 error

I have tried to build an installer for my codeigniter application and after completing af small form for collecting the database information it should execute a method for setting everything up.
This function is located in the install controller and the method is called runci and takes no arguments.
Currently looks like this:
PHP Code:
$data = array(
'status' => 'OK',
'http_response' => 200,
'message' => 'JSON data recieved'
My JS looks like this and is written in-line at the bottom of my view-file:
//AJAX call to submit and install
                var formdata = <?php print json_encode($_POST); ?>;
                try {
                    $.post('<?php print site_url(); ?>install/runci', formdata);
                catch(e) {
HTML output is correct, but after outputting the formdata to the console and then posting, I get this error back in the console:
POST http://ignitercms.khit.dev/install/runci 500 (Internal Server Error)
I know that something is wrong, but I cannot see what.

Only change from default CI 2.2.1 is that I have added wiredesignz HMVC Modular Extentions

It could be because you are returning your json instead of echoing it out back to the browser during the ajax request?

I have tried changing from return to echo and even to print, but still gives me same error in the console and nothing in CI log or php error log.

I fixed the issue. Seems like it could not handle it via post, so changed it to run using get requests.
//AJAX call to submit and install
     var formdata = <?php print json_encode($this->input->post(NULL, TRUE)); ?>;
         type: "GET",
         url: "<?php print site_url('install/runci'); ?>",
         data: formdata,
         success: function(msg) {

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.