PHP / Angular-调试“无法解析的响应”

时间:2018-10-01 13:35:23

标签: php angular laravel debugging

我正在研究我正在开发的Laravel / PHP网站上的一个错误(我对PHP很陌生)。从该单元格中删除值后,表格中的表项似乎没有从数据库中删除。

该表格单元格是用HTML编写的:

 with WrapperContext(condition) as obj:

当检测到表单元格的值发生更改时,表单元格的<td class="table__priority-column" [class.loading]="payer.loading" data-heading="RIT" id="reduceWidth-secondPlus"> <input style="min-width:100px;" type="text" [class.error]="payer.ritAmountError" *ngIf="!payer.loading" [(ngModel)]="payer.ritAmount" (change)="ritAmountChanged(payer)" [attr.disabled]="loadingPayers ? '' : null" /> </td> 属性将调用函数(change)。此功能在临时提示中定义为:

ritAmountChanged()

ritAmountChanged(payer) { console.log("ritAmountChanged() called from provisional-reminders.ts (line 487)"); if( payer.ritAmount === '' || payer.ritAmount === null ) { const errorMessage = new Message(); errorMessage.type = MessageType.ERROR; errorMessage.message = 'Please enter an RIT Amount.'; this.messagingService.emitMessage(errorMessage); this.currentDatePayer = null; //return false; /* remove the 'return' statement, to stop the function returning when the RIT value is set to null */ } ... this.provService.updateRitEstimate( payer.accountId, payer.ritIncomeYear, payer.ritAmount, filedDate ).subscribe( (response:any) => { payer.loading = false; const message = new Message(); message.type = MessageType.SUCCESS; message.message = response.message || 'Your RIT Estimate has been saved.'; this.messagingService.emitMessage(message); this.currentDatePayer = null; if( payer.calculateFromRIT ) { this.calculateAmountFromRIT( payer ); } }, (error:any) => { taxpayer.loading = false; const message = new Message(); message.type = MessageType.ERROR; message.message = error.message || 'There was a problem saving the RIT Estimate.'; this.messagingService.emitMessage(message); this.currentDatePayer = null; } ); } 调用的返回响应的updateRitEstimate()函数在provional.service.ts中定义为:

ritAmountChanged()

当我从表条目中的相关单元格中删除一个值时,我可以在控制台(updateRitEstimate(accountId: number, incomeYear: number, estimate: number, dateFiled?: any): Observable<any> { console.log("updateRitEstimate() called "); let headers = new Headers({ 'Content-Type': 'application/json' }); let data = { "accountId": accountId, "incomeYear": incomeYear, "estimate": estimate, "dateFiled": dateFiled }; console.log("data: ", data); return this.http .post(this.updateRitUrl, JSON.stringify( data ), {headers: headers}) .map(this.extractData) .catch(this.handleError); } )中看到调试,显示该值已设置为0,但是,紧接着,我在控制台中又收到一条消息,提示:

  

无法解释的反应

此消息不会显示为错误,它的显示方式与普通调试行的显示方式相同,只是一条普通消息。

鉴于此console.log("data: ", data);消息之前控制台中显示的最后一件事是unparseable response调试行,我怀疑问题与console.log("data: ", data);返回的响应有关函数...但是updateRitEstimate(...)返回的data变量内的信息似乎都是正确的,除了我期望删除的值是updateRitEstimate()的单元格,而不是而不是null(如果我将单元格的值更改为其他任何null值,我都会在调试行(即0中看到该值)。调试显示estimate: 123变量值为:

  

数据:{帐户ID:2771,收入年份:2019,估算值:0,日期归档:“ 8/10/2018”}

在控制台上显示data消息的同时,我在浏览器中看到一条错误提示,显示:

  

意外的令牌

从routes / web.php文件中,我可以看到用于更新值的PHP函数是ProvController.php中定义的unparseable response函数:

updateRITEstimate()

当我期望它为空时,如何跟踪在控制台中看到的public function updateRITEstimate( Request $request ) { $accountId = $request->input('accountId'); $incomeYear = $request->input('incomeYear'); $estimate = $request->input('estimate'); $filedDate = $request->input('dateFiled', ''); $save = $this->saveRITEstimate( $accountId, $incomeYear, $estimate, $filedDate ); if( $save ) { dd("save() function called, RIT estimate should have been saved/ removed "); return response()->json([ 'error' => false, 'message' => 'RIT Estimate received' ]); } else { dd("There was an error saving the RIT estimate "); return response()->json([ 'error' => true, 'message' => 'There was an error saving the RIT Estimate' ], 500); } } 消息的原因,以及为什么将unparseable response值设置为0?

0 个答案:

没有答案