i'm new to laravel 5.1. I had a question that how to call another controller within a blade?
here's the blade,
marks-management.blade.php
<body onLoad="init();">
<b>Course Code: </b> <select name="manufacturer" id="manufacturer" onChange="resetValues();doAjax('type_list.php', 'man='+getValue('manufacturer'), 'populateType', 'post', '1')">
<option value="">Please select:</option></select>
<b>Classification: </b> <select name="printertype" id="printertype" disabled="disabled" onChange="doAjax('model_list.php', 'man='+getValue('manufacturer')+'&typ='+getValue('printertype'), 'populateModel', 'post', '1')">
<option value="">Please select:</option></select>
<b>Index: </b> <select name="printermodel" id="printermodel" disabled="disabled" onChange="showOutput();">
<option value="">Please select:</option></select>
<div id="loading" style="display: none;"></div>
<div id="output"></div>
</body>
It's the cascading dropdown list, and i want to use Ajax to fetch data from database.
function init() {
doAjax('man_list.php', '', 'populateComp', 'post', '1');
}
And the doAjax function
function doAjax(url, query, callback, reqtype, getxml) {
var emptyselect = query.indexOf('Please select');
if(emptyselect >= 0) {
return;
}
var myreq = createREQ();
loader();
myreq.onreadystatechange = function() {
if(myreq.readyState == 4) {
if(myreq.status == 200) {
var item = myreq.responseText;
if(getxml == 1) {
item = myreq.responseXML;
}
doCallback(callback, item);
loader();
}
}
}
if(reqtype == 'post') {
requestPOST(url, query, myreq);
}
else {
requestGET(url, query, myreq);
}
}
This might call the other php to execute it. It works in PHP-only. But in laravel, it response that man_list.php not found, how can i solve it? Does it need other controller ??
And one problem, i'm not familiar with laravel(MVC structure), how can i transform the man_list.php into Laravel-like format?
man_list.php
<?php
include("dbconfig.inc.php");
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" ?>\n";
echo "<companies>\n";
$select = "SELECT * FROM course";
try {
foreach($dbh->query($select) as $row) {
echo "<Company>\n\t<id>".$row['course_id']."</id>\n\t<name>".$row['course_name']."</name>\n</Company>\n";
}
}
catch(PDOException $e) {
echo $e->getMessage();
die();
}
echo "</companies>";
?>
And it's the controller, i stuck into in a whole day.. no idea what should be added in
public function index()
{
return view('marks-management');
}
Thanks for the great help!!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire