jquery - Javascript Uncaught TypeError: showcreate1 is not a function -


i read before write questions other questions nothing work, check javascript loaded, try use jquery used $ nothing..

my problem ajax isn't working, error title question.

i have views, menu.blade.php code:

@extends('cms.public.layouts.default') @section('content')  <div class="col-md-10">     <h3 style="letter-spacing:40px;text-align:center;color:f15d5e;">proyectos</h3> </div> <div class="col-md-2" style="padding:20px;">   <button type="button" id="buttoncreate" class="btn btn-danger">crear proyecto</button>  </div> <div class="col-md-12" id="ajaxwindow">  </div>  <script>  $(document).ready(function(){       listproject();       $("#buttoncreate").click(function(e){         $("#buttoncreate").remove();         e.preventdefault();         listuploadproject();       });     });        var listproject = function()       {         $.ajax({           type:'get',           url:"{{ url('admin/project/listall') }}",           success: function(data){             $('#ajaxwindow').empty().html(data);           }         });       }       var listuploadproject = function()      {        $.ajax({          type:'get',          url:"{{ url('admin/project/create') }}",          success: function(data){            $('#ajaxwindow').empty().html(data);          }        });      } </script> @stop 

in view use ajax , working, shows view (listall.blade.php):

<table class="table">     <thead style="color:white">       <tr>         <th>id</th>         <th>slug</th>         <th>order</th>         <th>public</th>         <th>path header</th>         <th>path home</th>         <th>fecha creación</th>         <th>fecha ultima actualización</th>         <th><span class="glyphicon glyphicon-cog"></span></th>       </tr>     </thead>     <tbody style="color:white">      @foreach ($projects $key => $project)       <tr>         <th>{{$project->id}}</th>         <td>{{$project->slug}}</td>         <td>{{$project->order}}</td>         <td>{{$project->public}}</td>         <td>{{$project->pathheader}}</td>         <td>{{$project->pathhome}}</td>         <td>{{ date('m j, y', strtotime($project->created_at))}}</td>         <td>{{ date('m j, y', strtotime($project->updated_at))}}</td>         <td><a href="{{ route('admin.projects.show', $project->id)}}" class="btn btn-info btn-sm">view</a> <a href="{{ route('admin.project.edit', $project->id)}}" class="btn btn-success btn-sm">edit</a>     @endforeach       </tr>     </tbody>   </table>   <br><br> 

and if click on button create goes view (createproject.blade.php):

<div class="col-md-8 col-md-offset-2" id="createproject">  </div> <br><br><br>  <script> $(document).ready(function(){         showcreate1();     });        var showcreate1 = function()       {         $.ajax({           type:'get',           url:"{{ url('admin/project/createform1') }}",           success: function(data){             $('#createproject').empty().html(data);           }         });       } </script> 

the url '/admin/project/createform1' called controller:

 public function createprojectform1()    {        return view('cms.public.views.projects.createprojectform1');    }       <div class="col-md-10">         <h3>crear nuevo proyecto</h3>         </div>         <div class="col-md-2">         <h3>1/2</h3>         </div>         <hr>           <div class="col-md-12" id="formcreateproject">              <form method="post" action="{{ route('admin.projects.store') }}" enctype="multipart/form-data">               <div class="form-group">                 <label name="title">slug:</label>                 <input type="text" id="slug" name="slug" placeholder="ejemplo-de-slug" class="form-control form-control-sm">                 <label name="order">order:</label>                 <input type="number" id="order" name="order" class="form-control form-control-sm">                 <label name="public">public:</label>                 <input type="number" id="public" name="public" class="form-control form-control-sm">                  <label name="body">header</label>                 <input type="file" name="pathheader" id="pathheader"  class="form-control-file" aria-describedby="filehelp"><br>                 <label name="body">home</label>                 <input type="file" name="pathhome" id="pathhome" class="form-control-file" aria-describedby="filehelp"><br>                  <input type="submit" value="crear proyecto" id="createprojectsubmit" class="btn btn-danger btn-md">                 <input type="hidden" name="_token" value="{{ session::token() }}">                 <br><br><br>                </div>             </form>            </div> 

why last view isn't loaded?

thanks lot, appreciated.

try using this

showcreate1 = function()       {         $.ajax({           type:'get',           url:"{{ url('admin/project/createform1') }}",           success: function(data){             $('#createproject').empty().html(data);           }         });       } 

without var. declaring var limit it's scope. removing var make global function can accessed in page, or instead

$(document).ready(function(){        var showcreate1 = function()       {         $.ajax({           type:'get',           url:"{{ url('admin/project/createform1') }}",           success: function(data){             $('#createproject').empty().html(data);           }         });       }         showcreate1();     }); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -