Hi guys i am working in magento and i have searched a lot but didn't get any solution this is my ajax
嗨,大家好我在magento工作,我搜索了很多,但没有得到任何解决方案这是我的ajax
var $wk_jq = jQuery.noConflict();
$wk_jq.ajax({
url : "<?php echo $this->getUrl('mpmassuploadaddons/index/runProfiler'); ?>",
type : 'GET',
data : {id : profilerId,row : countOfStartedProfiles},
dataType : 'json',
success : function(content) {
console.log('content success');
},
error: function(xhr, textStatus, errorThrown) {
console.log(xhr);
console.log(textStatus);
console.log(errorThrown);
}
});
I am getting parsererror always
我总是得到parsererror
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
responseText "NULL\nNULL\n{"savedRows":1...":"successfully saved"}"
status 200
statusText "OK"
even my php code is working fine and returning json encode string {"savedRows":1,"success":"successfully saved"}
with success message here is my php code
即使我的PHP代码工作正常并返回json编码字符串{“savedRows”:1,“成功”:“成功保存”}成功消息这里是我的PHP代码
public function runProfilerAction() {
ob_start();
$profileId = $this->getRequest()->getParam('id');
$rowCount = $this->getRequest()->getParam('row');
$profile = Mage::getModel('mpmassuploadaddons/profilesession')->load($profileId);
if($profile->getproductType() == "simple") {
$result = Mage::getModel('mpmassuploadaddons/mpmassupload')->importSimpleProducts($profileId,$rowCount);
} elseif($profile->getproductType() == "downloadable") {
$result = Mage::getModel('mpmassuploadaddons/mpmassupload')->importDownloadableProducts($profileId,$rowCount);
} elseif($profile->getproductType() == "virtual") {
$result = Mage::getModel('mpmassuploadaddons/mpmassupload')->importVirtualProducts($profileId,$rowCount);
} elseif($profile->getproductType() == "configurable") {
$result = Mage::getModel('mpmassuploadaddons/mpmassupload')->importConfigurableProducts($profileId,$rowCount);
}
echo json_encode($result);
}
This json {"savedRows":1,"success":"successfully saved"}
is also in correct format i have decode it here http://json.parser.online.fr/
这个json {“savedRows”:1,“成功”:“成功保存”}也是正确的格式我在这里解码它http://json.parser.online.fr/
and its fine please help thanks
它的罚款请帮忙谢谢
1 个解决方案
#1
1
Add this
ob_clean();
before json_encode
Hopefully it works...
希望它有效......
#1
1
Add this
ob_clean();
before json_encode
Hopefully it works...
希望它有效......