Internal Server Error - 500 on post when CSRF disabled |
[eluser]joshmmo[/eluser]
So this is the error when I open it in a tab: Code: A PHP Error was encountered Thats this line: Code: foreach ($order as $question_number => $question_id) { Why would the foreach fail only when I make that call to my model?
[eluser]jonez[/eluser]
[quote author="joshmmo" date="1386889099"]So this is the error when I open it in a tab: Code: A PHP Error was encountered Thats this line: Code: foreach ($order as $question_number => $question_id) { Why would the foreach fail only when I make that call to my model?[/quote] $order isn't an array, data isn't being posted properly. Add the boom statement I added above but change to die(var_dump($order)); In your JS function console.log your serialize call, there's a chance it's not returning data the way you think it is.
[eluser]joshmmo[/eluser]
I would have never guessed that. Thanks for pointing that out. It now throws: boolean false on die. This is what console.log shows for order: recordsArray[]=2&recordsArray;[]=6&recordsArray;[]=1&recordsArray;[]=8&action=updateRecordsListings How would I go about getting this data into a php array on post? Ignore the ;. These forums keep adding them in for some reason when I save my reply Here is a SS of it instead: http://i44.tinypic.com/jq0vh1.png
[eluser]jonez[/eluser]
Click the little + beside the AJAX call showing the 500 and check out the Params tab. Does it show your post data the same as your console.log? jQuery attempts to auto detect your data's type (it could be JSON, a string, etc) and may be processing it. Write your AJAX call like this and see what happens; Code: $.ajax({
[eluser]CroNiX[/eluser]
You should probably also post the raw HTML (output) of what your drag and drop section looks like. If your controller is receiving boolean FALSE, it means that it wasn't actually sent and that POST variable did not exist. Jonez is on the right track. It seems to be a problem in the JS or HTML resulting in inconsistent data being sent to the controller.
[eluser]joshmmo[/eluser]
This is the tab: http://i44.tinypic.com/20gefev.png However I am still getting boolean false on Code: if (!is_array($order))die(var_dump($order)); Thanks for helping me sort through this jonez. Is there a way to tell for sure what data type jquery is trying to send it as? This is what my html looks like for the drag/drop Code: <div id="status"></div>
[eluser]jonez[/eluser]
[quote author="CroNiX" date="1386955679"]You should probably also post the raw HTML (output) of what your drag and drop section looks like. If your controller is receiving boolean FALSE, it means that it wasn't actually sent and that POST variable did not exist. Jonez is on the right track. It seems to be a problem in the JS or HTML resulting in inconsistent data being sent to the controller.[/quote] You can also die(var_dump($this->input->post())); in CI to see everything the client sent to the server. Change your markup to this; Code: <ul id="order" class="list-group"> Then change your JS function to this; Code: var order = $( '#order' ).children( ),
[eluser]joshmmo[/eluser]
Thanks for the help! It seems I am getting posts just fine now, I see a new error message but I know what the issue is now. Thank you guys for your time.
|
Welcome Guest, Not a member yet? Register Sign In |