簡體   English   中英

position 0 處的 JSON 中的意外令牌 A?

[英]Unexpected token A in JSON at position 0?

web.php

Route::post('portal/student_exam_info_edit','PortalOperation@student_exam_info_edit');

Controller 它是我的門戶操作 controller 我想在請求中顯示數據但我顯示錯誤

  public function student_exam_info_edit(Request $request)
    {
             print_r($request->all());
    }

student_exam_info.blade.php

@extends('layouts.portal')
@section('title','Exam Form')
@section('content')
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">Student Exams Info</h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">Student Exams Info</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content-header -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <!-- Default box -->
                        <div class="card">
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-sm-6">
                                        <h3> {{ $exam_info->title }}</h3>
                                    </div>
                                    <div class="col-sm-6">
                                        <h3> <span class="float-right">{{ date('d M,y',strtotime($exam_info->exam_date ))}}</span></h3>
                                    </div>
                                </div>
                                <form action="{{ url('portal/student_exam_info_edit') }}" class="database_operation">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter Name</label>
                                                {{ csrf_field() }}
                                                <input type="hidden" name="id" value="{{ $student_info[0]['id'] }}">
                                                <input type="text" name="name" required="required" value="{{ $student_info[0]['name'] }}" placeholder="Enter Name" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter E-Mail</label>
                                                <input type="text" required="required" name="email" value="{{ $student_info[0]['email'] }}" placeholder="Enter E-Mail" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter Mobile No</label>
                                                <input type="text" name="mobile_no" value="{{ $student_info[0]['mobile_no'] }}" placeholder="Enter Mobile No" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Select DOB</label>
                                                <input type="date" name="dob" value="{{ $student_info[0]['dob'] }}"  class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter Password</label>
                                                <input type="password" name="password"   placeholder="Enter Password" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <button class="btn btn-info"> Update</button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>

                            <!-- /.card-body -->

                            <!-- /.card-footer-->
                        </div>
                        <!-- /.card -->
                    </div>
                </div>
            </div>
        </section>
    </div>
@endsection

自定義.js

$(document).on('submit','.database_operation',function () {
    var url=$(this).attr('action');
    var data=$(this).serialize();
    $.post(url,data,function (fb) {
             var resp=$.parseJSON(fb)
        if(resp.status=='true')
        {
           alert(resp.message) ;
           setTimeout(function () {
               window.location.href = resp.reload;
           },1000);
           }
           else
        {
            alert(resp.message) ;
        }
    })
    return false;
});
$(document).on('click','.category_status',function () {
var id=$(this).attr('data-id');
$.get(BASE_URL+'/admin/category_status/'+id,function (fb) {
    alert('Status Successfully Changed');
})
});
$(document).on('click','.exam_status',function () {
    var id=$(this).attr('data-id');
    $.get(BASE_URL+'/admin/exam_status/'+id,function (fb) {
        alert('Status Successfully Changed');
    })
});
$(document).on('click','.student_status',function()
{
    var id=$(this).attr('data-id');
    $.get(BASE_URL+'/admin/student_status/'+id,function (fb) {
        alert('Status Successfully Changed');
    })
})
$(document).on('click','.portal_status',function()
{
    var id=$(this).attr('data-id');
    $.get(BASE_URL+'/admin/portal_status/'+id,function (fb) {
        alert('Status Successfully Changed');
    })
})

錯誤當我更新表格並檢查檢查元素網絡時,我無法理解這個錯誤是什么意思意味着如何解決我找到解決方案幾個小時但無法解決

VM2391:1 Uncaught SyntaxError: Unexpected token A in JSON at position 0
    at Function.parse [as parseJSON] (<anonymous>)
    at Object.success (custom.js:5)
    at c (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at l (jquery.min.js:2)
    at XMLHttpRequest.<anonymous> (jquery.min.js:2)
(anonymous) @ custom.js:5
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
l @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
load (async)
send @ jquery.min.js:2
ajax @ jquery.min.js:2
k.<computed> @ jquery.min.js:2
(anonymous) @ custom.js:4
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2

請檢查帖子值,我認為您輸入了錯誤的輸入/類型

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM