[英]I am getting console error during soap call using codeigniter
I am getting this error when I am trying to imitate a SOAP
call using AJAX
当我尝试使用AJAX
模仿SOAP
调用时出现此错误
Uncaught SyntaxError: Unexpected token < in JSON at position 0
My AJAX
call is looking like this 我的AJAX
通话看起来像这样
$.ajax({
type: "POST",
url: '<?php echo base_url();?>getStatus/index',
data: {devices: deviceString},
success: function(data) {
var obj = JSON.parse(data);
});
In my controller : 在我的控制器中:
$client = new SoapClient("http://example.com:8080/app/app?WSDL");
$result=$client->getStatus($para);
$array = json_decode(json_encode($result), true);
so anyone has what could be the reason getting this error? 所以任何人都有可能是收到此错误的原因?
禁用CSRF或将CSRF令牌与您的数据一起发布
You need to pass dataType
parameter while initializing your ajax call, which will tell the jquery ajax call that what type of data is expected in response, by default it expects json if you dont mention it. 您需要在初始化ajax调用时传递dataType
参数,这将告诉jquery ajax调用期望响应的数据类型,默认情况下,如果您不提及它,则期望json。
$.ajax({
data: {devices: deviceString}, // what you are sending
dataType: 'html', // what you are expecting
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.