简体   繁体   English

在使用Codeigniter进行Soap调用期间出现控制台错误

[英]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.

相关问题 更新到 Codeigniter 3.x 后,为什么在 ajax 调用期间出现 json 解析错误? - Why am I getting a json parse error during an ajax call after updating to Codeigniter 3.x? 我在codeigniter中遇到错误 - I am getting error in codeigniter 记录正在更新,但我仍然在控制台中收到此错误 - Record is getting updated but I am still getting this error in console 在Ember设置过程中,出现“ ETIMEDOUT错误” - During Ember setup, I am getting a “ETIMEDOUT error” 为什么我在获取 api 期间收到这些错误 - why i am getting these error during fetch api 我在控制台日志中得到的“ $不是函数”错误消息是什么? - What I am getting “ $ is not a function ” error message in console log ? 我在控制台中收到此错误:无法读取未定义的属性“ some” - I am getting this error in the console : Cannot read property 'some' of undefined 我在控制台中遇到错误,无法在JavaScript中读取属性tostring() - i am getting error in console can not read property tostring() in javascript 我在使用事件时在控制台中遇到了一些错误 - I am getting some errors in console while using events 为什么我在使用数组 concat 时不断收到 TypeScript 错误“没有重载匹配此调用”? - Why am I keep getting TypeScript error “No overload matches this call” when using Array concat?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM