Posting a JSON string using dojo.xhrPost

I am having a problem sending a JSON string using dojo.xhrPostin the Zend Framework Controller.

When I send a string to the server, I do not receive any data. I even tried just sending the "test string", even if it is not sent.

I dumped var to see the contents of the request, but as clear as day, there are no parameters or data of what I am posting. My code is as follows:

var jsonStr = dojo.toJson(values);
var xhrArgs = ({
        url:"/dojo/savedetails/",
        postData: jsonStr,
        handleAs: "text",               
        load: function(data){

            if(data == 'success'){

                //success code
               dojo.byId('edit_alert').innerHTML = '<div class="info">Your changes have been saved</div>'

            }else{

                dojo.byId('edit_alert').innerHTML = '<div class="error">We were unable to save your changes please try again.</div>';
            }

        }           

    });

    //we now post the data to the server for processing.
    var deferred = dojo.xhrPost(xhrArgs);

My content var_dump($this->_request):

object(Zend_Controller_Request_Http)#118 (14) { ["_paramSources":protected]=>  
array(2) { [0]=>  string(4) "_GET" [1]=>  string(5) "_POST" } ["_requestUri":protected]=>  string(25) "/dojo/savedetails/" 
["_baseUrl":protected]=>  string(0) "" ["_basePath":protected]=>  NULL ["_pathInfo":protected]=>  string(25) "/dojo/savedetails/" ["_params":protected]=>
array(3) { ["controller"]=>  string(4) "dojo" ["action"]=>  string(18) "savedetails" ["module"]=>  string(7) "default" } ["_aliases":protected]=>  array(0)
{ } ["_dispatched":protected]=>  bool(true) ["_module":protected]=>  string(7) "default" ["_moduleKey":protected]=>  string(6) "module" 
["_controller":protected]=>  string(4) "dojo" ["_controllerKey":protected]=>  string(10) "controller" ["_action":protected]=>  
string(18) "savedetails" ["_actionKey":protected]=>  string(6) "action" } 

I hope that I am missing something simple, but I am following the documentation on dojotoolkit.org, and from their examples this should work.

I am using Dojo 1.3 and Zend Framework 1.9 if this helps.

Thank,

+3
2

postData , dojo.rawXhrPost dojo.xhrPost.

+3

content postData. , Firebug (firefox), (chrome/IE) Fiddler , HTTP-.

0

Source: https://habr.com/ru/post/1758020/


All Articles