hecate0211

Experience

110

0 Best Reply Awards

  • Member Since 1 Week Ago
  • 0 Lessons Completed
  • 0 Favorites

18th September, 2017

hecate0211 left a reply on How To Send Array From Script To Controler • 4 days ago

@Dry7 bro, when i send the array.. why i got null when use

 $data = json_decode($request->getContent());

and when i use

$data2 = $request->getContent();

the result i got

16th September, 2017

hecate0211 left a reply on How To Send Array From Script To Controler • 5 days ago

@Dry7 oh iknow my error thanks for ur big help bro

hecate0211 left a reply on How To Send Array From Script To Controler • 5 days ago

@Dry7 i already use in my code


public function saveJson($request)
        {
            $data = json_decode($request->getContent());
        }

and got error


(1/1) FatalThrowableError
Type error: Too few arguments to function App\Http\Controllers\RabController::saveJson(), 0 passed and exactly 1 expected```

hecate0211 left a reply on How To Send Array From Script To Controler • 5 days ago

@Dry7 this is my full code

view

<button class="btn btn-primary" id='save' onclick="sendData()">Import File</button>

<script type="text/javascript">
              function sendData() {
                  var data = [
                      1,
                      2,
                      3
                    ];
                  $.ajax({
                      url:'/test',
                      type: 'POST',
                      dataType:'json',
                      contentType: 'json',
                      data: {data:JSON.stringify(data)},
                      contentType: 'application/json; charset=utf-8',
                  });
              }
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

route

Route::post('/test','RabController@saveJson');

controller

public function saveJson($request)
        {
            $data = json_decode($request->getContent());

        }

hecate0211 left a reply on How To Send Array From Script To Controler • 5 days ago

@Dry7

(1/1) FatalThrowableError
Type error: Too few arguments to function App\Http\Controllers\RabController::saveJson(), 0 passed and exactly 1 expected

i got this error

hecate0211 left a reply on How To Send Array From Script To Controler • 5 days ago

@Dry7 but how to send the json to controller?? i try use

var jsonPost = JSON.stringify(dataTables);
                alert(jsonPost);
                
                $.ajax({
                    url:'/tes',
                    type: 'POST',
                    dataType:'json',
                    contentType: 'json',
                    data: {data:jsonPost}
                });

but i dont know if it work or not i still confuse can u teach me bro?

14th September, 2017

hecate0211 started a new conversation How To Send Array From Script To Controler • 1 week ago

i want to send my array to controller, but i idont understand how to send it

this is my view

Import File

this is my script document.querySelector('#save').addEventListener('click', function() { var dataTables = []; var rows = hot.countRows()-20; var cells = hot.countCols();

            for(i =1; i<rows;i++){
                  dataTables = [dataTables, [hot.getDataAtCell(i,0), hot.getDataAtCell(i,1),
                  hot.getDataAtCell(i,2),hot.getDataAtCell(i,3),hot.getDataAtCell(i,4),
                  hot.getDataAtCell(i,5)]];
            }
            
          });

can someone help me?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.