admin管理员组文章数量:1419220
I am having an issue trying to post a JSON string using dojo.xhrPost
to a Zend Framework Controller.
When I post the string to the server I get no data being sent. I've even tried just sending "A Test string", even that is not being sent.
I've done a var dump to see the contents of the request but clear as day, there is no parameter or data of what I am posting. My code looks like this:
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);
The contents of my var_dump($this->_request)
is:
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 however I've been following the documentation on dojotoolkit, and from their examples this should work.
I'm Using Dojo 1.3 and Zend Framework 1.9 if that helps.
Thanks,
I am having an issue trying to post a JSON string using dojo.xhrPost
to a Zend Framework Controller.
When I post the string to the server I get no data being sent. I've even tried just sending "A Test string", even that is not being sent.
I've done a var dump to see the contents of the request but clear as day, there is no parameter or data of what I am posting. My code looks like this:
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);
The contents of my var_dump($this->_request)
is:
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 however I've been following the documentation on dojotoolkit, and from their examples this should work.
I'm Using Dojo 1.3 and Zend Framework 1.9 if that helps.
Thanks,
Share Improve this question edited Aug 12, 2010 at 7:29 bakkal 55.5k12 gold badges136 silver badges113 bronze badges asked Aug 4, 2010 at 14:18 Grant CollinsGrant Collins 1,7915 gold badges31 silver badges47 bronze badges2 Answers
Reset to default 3If you use postData
to pass in the content, you need to use dojo.rawXhrPost
instead of dojo.xhrPost
.
Try content
instead of postData
. Also, load up Firebug (firefox), Developer Tools (chrome/IE), or Fiddler and see what the actual outgoing HTTP request looks like.
本文标签: javascriptPosting JSON string using dojoxhrPostStack Overflow
版权声明:本文标题:javascript - Posting JSON string using dojo.xhrPost - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745301630a2652404.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论