Welcome Guest, Not a member yet? Register   Sign In
Read JSON response from Ext JS giving boolean false?!
#1

[eluser]CI_adis[/eluser]
Hi all,

I'm stuck with something... I tried to integrate Ext JS with CI and it works well. But when I submit something from Ext JS it returns a JSON object and I cannot read the content in my CI controller. The JSON is:

Code:
{
    "tasks": [
        {
            "taskId": "4",
            "taskCode": "777",
            "taskDescription": "Fix this",
            "taskDuration": "1",
            "reqCompletionDateTime": "2011-08-25T12:00:00",
            "customerId": "",
            "customerCode": "",
            "customerName": ""
        }
    ]
}

But when I want to read this in my controller:

Code:
var_dump($this->input->post());

It is giving me the error:

Quote:<pre class='xdebug-var-dump' dir='ltr'><small>boolean</small> <font color='#75507b'>false</font>
</pre>

The complete function in my controller:
Code:
function update_all_tasks()
     {
        var_dump($this->input->post());
     }

What can this be, I cannot find anything else that is weird??
If I create a test.html with one textfield and enter my json in that field I can read the response...
#2

[eluser]SlavomirJ[/eluser]
False means that Your POST request is empty. Try to check if You are actually getting any date by checking $_REQUEST variable, maybe result is a GET reqest? Smile
#3

[eluser]CI_adis[/eluser]
Hi slavomir,

This is my request:

Code:
Request URL:http://localhost:8888/app/index.php/process_tasks/update_all_tasks?_dc=1313184225354
Request Method:POST
Status Code:200 OK

Code:
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:205
Content-Type:application/json
Cookie:bmeval=1312738020402; tp_session=a:4:{s:10:"session_id";s:32:"5068c6013d8dc508e0b4a6e5633e4a54";s:10:"ip_address";s:11:"192.168.1.2";s:10:"user_agent";s:50:"Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/53";s:13:"last_activity";i:1313184214;}f5b1905ab0cab751d6e95187d5449f92
Host:localhost:8888
Origin:http://localhost:8888
Referer:http://localhost:8888/app/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1
X-Requested-With:XMLHttpRequest

And in the request payload I see the JSON as mentioned in first post..
So my request is not empty, right??
#4

[eluser]CI_adis[/eluser]
I can read the JSON when I use this:

Code:
$result = NULL;
        if(function_exists('json_decode')) {
            $jsonData = json_decode(trim(file_get_contents('php://input')), true);
            $result = $jsonData['tasks'][0];
        }
        return $result;

sow this is not working:
Code:
var_dump($_POST);
or
Code:
var_dump($this->input->post());
and this is working:
Code:
file_get_contents('php://input')
is this a bug in 2.0.2??




Theme © iAndrew 2016 - Forum software by © MyBB