- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个 Web 应用程序,它接收用户的输入、查询 API、使用 PHP 处理数据,然后使用 jQuery 和 D3 将其呈现为一系列图表。我最初以程序方式设置它,但此后一直使用 Laravel 框架来实现它。我遇到的问题是 JavaScript 在最终页面中无法正常工作;我认为这与 Blade 模板系统的工作方式有关。
我知道它在加载初始图表时正在正确访问 JavaScript 文件。但是,还有一些额外的功能可以根据不同的时间跨度重新加载图表以及滚动图表中的数据。加载页面后,所有 jQuery 内容都不起作用。
无论如何,这是代码:
路由: routes.php
(app\Http)
<?php
// perform GET request on root and call method 'index' on the PagesController class
// (app/Http/Controllers/PagesController.php)
Route::get('/', 'PagesController@index');
// perform POST on 'data' and call method 'process' on the PagesController class
Route::post('data', 'PagesController@process');
?>
基本模板: app.blade.php
(资源\ View )
<!DOCTYPE HTML>
<html lang="en">
<head>
{{-- this stops the default compatibility view for intranet sites in IE --}}
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<title>Academic Intelligence</title>
{{-- LINKS --}}
{{-- local css file --}}
{!! HTML::style('css/style.css') !!}
{{-- bootstrap css (bootswatch readable style) --}}
{!! HTML::style('//maxcdn.bootstrapcdn.com/bootswatch/3.3.0/readable/bootstrap.min.css') !!}
{{-- SCRIPTS --}}
{{-- jquery --}}
{!! HTML::script('https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js') !!}
{{-- bootstrap js --}}
{!! HTML::script('//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js') !!}
</head>
<body>
{{-- TITLE BAR --}}
<div class="sg-titlebar">
<h1><a title="Newcastle University Homepage" accesskey="1" href="http://www.ncl.ac.uk/"/><span title="Newcastle University">Newcastle University</span></a></h1>
<h2><a href="https://resviz.ncl.ac.uk/wos/">Academic Intelligence</a></h2>
</div>
<div class="sg-content">
{{-- NAVIGATION BAR --}}
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ action('PagesController@index') }}"><span class="glyphicon glyphicon-home"></span></a></li>
<li><a href="{{ action('PagesController@about') }}">About</a></li>
</ul>
</div> {{-- navbar-collapse --}}
</div> {{-- container --}}
</nav> {{-- navbar --}}
{{-- main content --}}
<section class="container">
{{-- unique section to other pages --}}
@yield('content')
</section> {{-- main content; container --}}
</div> {{-- sg-content --}}
{{-- FOOTER --}}
</body>
</html>
主页: home.blade.php
(资源\ View \页面)
{{-- this HTML is inserted into app.blade.php as content --}}
@extends('app')
@section('content')
{{-- local script --}}
{!! HTML::script('js/script.js') !!}
<div class="row">
{{-- search form --}}
{{-- using Illuminate\Html\HtmlServiceProvider package --}}
{!! Form::open(['url' => 'data', 'id' => 'form']) !!}
<fieldset>
<div class="form-group">
{{-- see http://getbootstrap.com/css/#grid for explanation of Bootstrap grid system --}}
<div class="col-lg-6 well bs-component">
{{-- 'journal(s) section of form' --}}
<div class="journal_fields_wrap">
{{-- 'journal(s)' section header --}}
<h4 class="form_title">Journal</h4>
{{-- buttons above 'journal(s)' input boxes --}}
<div class="journal_buttons">
{{-- loads a list of journals on Web of Science --}}
<a class="btn btn-success" target="_blank" href="http://ip-science.thomsonreuters.com/cgi-bin/jrnlst/jloptions.cgi?PC=D"
data-toggle="tooltip-down" title="Search Thomson Reuters for journals">Journal List</a>
{{-- add extra input field for journals --}}
{!! Form::button('<span class="glyphicon glyphicon-plus"></span> Add more fields', ['class' => 'add_journal_field_button btn btn-info']) !!}
</div> {{-- journal_buttons --}}
{{-- input box for journal(s) --}}
<div class="form_field">
{{-- parameters: textbox(name, default value, options array) --}}
{!! Form::text('journal1', null, ['class' => 'form-control', 'data-toggle' => 'tooltip-right', 'title' => 'Please enter only one journal per box']) !!}
</div> {{-- form_field --}}
</div> {{-- journal_fields_wrap --}}
{{-- 'keyword(s)' section of form --}}
<div class="title_fields_wrap">
{{-- 'keyword(s)' section header --}}
<h4 class="form_title">Keyword</h4>
{{-- buttons above 'keyword(s)' input boxes --}}
<div class="title_buttons">
{{-- add extra input field for keywords --}}
{!! Form::button('<span class="glyphicon glyphicon-plus"></span> Add more fields', ['class' => 'add_title_field_button btn btn-info']) !!}
</div> {{-- title_buttons --}}
{{-- input box for keyword(s) --}}
<div class="form_field">
{{-- parameters: textbox(name, default value, options array) --}}
{!! Form::text('title1', null, ['class' => 'form-control', 'data-toggle' => 'tooltip-right', 'title' => 'Please enter only one title per box']) !!}
</div> {{-- form_field --}}
</div> {{-- title_fields_wrap --}}
{{-- 'time span' section of form; header --}}
<h4 class="form_title">Time Span</h4></br>
{{-- 'From:' header --}}
{!! Form::label('select', 'From:', ['class' => 'col-lg-2 control-label']) !!}
<div class="col-lg-3">
{{-- parameters: selectbox(name, [data], default, [options]) --}}
{{-- data (years) provided by script.js --}}
{!! Form::select('timeStart', [], 'Select', ['class' => 'form-control', 'id' => 'select']) !!}
</div> {{-- col-lg-3 --}}
{{-- 'To:' header --}}
{!! Form::label('select', 'To:', ['class' => 'col-lg-2 control-label']) !!}
<div class="col-lg-3">
{{-- as other select box above --}}
{!! Form::select('timeEnd', [], 'Select', ['class' => 'form-control', 'id' => 'select']) !!}
</div> {{-- col-lg-3 --}
<br/><br/>
{{-- execute search; submit button --}}
{{-- parameters: button(text on button, [options]) --}}
{!! Form::button('<strong>Submit</strong><span class="glyphicon glyphicon-transfer"></span>', ['type' => 'submit', 'class' => 'btn btn-primary btn-lg', 'id' => 'submit']) !!}
</div> {{-- col-lg-6 --}}
<div class="col-lg-6 well bs-component">
{{-- bootstrap window --}}
<div class="modal-dialog">
<h4>Notes</h4>
<p>This application is optimised for Chrome.</p>
<p>In order to get the best results from your search,<br/>enter one or more journals.</p>
<p>Keywords and time spans are optional but can be<br/>used to refine your search.</p>
</div> {{-- modal-dialog --}}
</div> {{-- col-lg-6 --}}
</div> {{-- form-group --}}
</fieldset>
{!! Form::close() !!}
</div> {{-- row --}}
@stop
数据显示: data.blade.php
(资源\ View \页面)
@extends('app')
@section('content')
<!-- d3 -->
{!! HTML::script('https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.min.js') !!}
<!-- local script -->
{!! HTML::script('js/graphs.js') !!}
<section class="graphs container">
<div class="row col-lg-12" id="header">
<div class="col-lg-1"></div>
<div class="panel panel-info col-lg-7">
<div class="panel-heading">
<h2 class="panel-title">Search Parameters</h2>
</div>
<div class="panel-body">
<div id="journalData"></div>
<div id="keywordData"></div>
<div id="timescaleData"></div>
</div>
</div> <!-- panel panel-info -->
<div class="dropdown col-lg-2">
<div class="form-group">
<label for="select" class="control-label">Change time span:</label>
<select class="form-control" id="timeSelect">
<option value="chart2" selected>User defined</option>
<option value="chart4">Last 10 years</option>
<option value="chart5">Last 5 years</option>
<option value="chart6">Last 2 years</option>
</select>
</div>
</div> <!-- dropdown -->
<div class="col-lg-2"></div>
</div> <!-- row -->
<div class="graph_fields_wrap row backdrop col-lg-12">
<div class="col-lg-6">
<h3 class="titles">Ranked Author Citations</h3>
<h4 class="titles">All time (from 1970)</h4>
<button class="pager" id="previous1" type="button" disabled><span class="glyphicon glyphicon-chevron-left"></span> previous</button>
<button class="pager indexer" type="button" disabled>1 - 10</button>
<button class="pager" id="next1" type="button">next <span class="glyphicon glyphicon-chevron-right"></span></button>
<div class="chart1 well bs-component"></div>
</div>
<div class="col-lg-6">
<h3 class="titles">Ranked Author Citations</h3>
<h4 class="titles" id="userTitle"></h4>
<button class="pager" id="previous2" type="button" disabled><span class="glyphicon glyphicon-chevron-left"></span> previous</button>
<button class="pager indexer" type="button" disabled>1 - 10</button>
<button class="pager" id="next2" type="button">next <span class="glyphicon glyphicon-chevron-right"></span></button>
<div class="chart2 well bs-component"></div>
</div>
</div> <!-- row -->
</br>
<div class="row col-lg-12">
<div class="row backdrop col-lg-7" id="impact">
<h3 class="titles">Weighted Citation Factor</h3>
<h4 class="titles">All time (from 1970)</h4>
<div class="well bs-component" id="rankChart">
<div class="chart3"></div>
</div>
</div> <!-- row -->
<div class="backdrop col-lg-5" id="algorithm">
<h3 class="titles">Explanation of Bubble Chart</h3>
<div class="well bs-component">
<p>The weighted citation factor applies a weighting to citations based on the year of publication. The more recent the citation, the higher the weighting.</p>
<p>This chart takes into account data from all years. The higher the weighted citation factor, the larger the bubble.</p>
</div>
</div>
</div> <!-- col-lg-12 -->
</br>
<div class="graph_fields_wrap2 row backdrop col-lg-12">
<div class="col-lg-6">
<h3 class="titles">Ranked Awarded Funds (£millions)</h3>
<h4 class="titles">All time, UK only</h4>
<div class="chart7 well bs-component"></div>
</div>
<div class="col-lg-6">
<h3 class="titles">Ranked Awarded Funds (£millions)</h3>
<h4 class="titles userTitle">, UK only</h4>
<div class="chart8 well bs-component"></div>
</div>
</div> <!-- row -->
</section>
@stop
PHP 处理: PagesController.php
(app\Http\Controllers)
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Request;
use App\SoapController;
use App\Models\SearchData;
use App\Models\SoapWrapper;
use App\Models\RestWrapper;
use App\Models\DataSort;
use App\Models\BubbleChartCompatible;
use DB;
use View;
use Laracasts\Utilities\JavaScript\JavaScriptFacade as JavaScript;
class PagesController extends Controller {
public function __construct()
{
$this->middleware('guest');
}
// method index returns view 'home' (resources/views/home.blade.php)
public function index()
{
return view('pages.home');
}
// method process returns view 'data' (resources/views/data.blade.php)
public function process()
{
... processes data ...
// pass data to JavaScript (uses https://github.com/laracasts/PHP-Vars-To-Js-Transformer)
JavaScript::put([
'allCited' => $allCited,
'userCited' => $userCited,
'tenCited' => $tenCited,
'fiveCited' => $fiveCited,
'twoCited' => $twoCited,
'valueData' => $valueData,
'allFunded' => $allFunds,
'userFunded' => $userFunds,
'tenFunded' => $tenFunds,
'fiveFunded' => $fiveFunds,
'twoFunded' => $twoFunds,
'searchData' => $searchParams
]);
return View::make('pages.data');
}
}
JAVASCRIPT: graphs.js
(public\js)
$(document).ready(function() {
// pull data from PHP
// CITES
var allCitedData = $.parseJSON(Graphs.allCited);
var userCitedData = $.parseJSON(Graphs.userCited);
var tenCitedData = $.parseJSON(Graphs.tenCited);
var fiveCitedData = $.parseJSON(Graphs.fiveCited);
var twoCitedData = $.parseJSON(Graphs.twoCited);
// VALUES; leave in JSON format
var valueData = Graphs.valueData;
// FUNDS
var allFundedData = $.parseJSON(Graphs.allFunded);
var userFundedData = $.parseJSON(Graphs.userFunded);
var tenFundedData = $.parseJSON(Graphs.tenFunded);
var fiveFundedData = $.parseJSON(Graphs.fiveFunded);
var twoFundedData = $.parseJSON(Graphs.twoFunded);
// USER SEARCH PARAMETERS
var searchData = Graphs.searchData;
// different colour settings for graphs
var palette1 = {
fill: "steelblue",
hover: "brown"
};
var palette2 = {
fill: "seagreen",
hover: "darkorange"
};
var palette3 = {
fill: "darkblue",
hover: "darkmagenta"
};
var palette4 = {
fill: "darkolivegreen",
hover: "darkseagreen"
};
// set title for user defined graph
var graphTitle = $(".userTitle");
console.log(searchData.from + " to " + searchData.to);
graphTitle.prepend(searchData.from + " to " + searchData.to);
// change graph according to dropdown choice
var wrapperG = $(".graph_fields_wrap1"); // wrapper for div containing citations graphs
var wrapperF = $(".graph_fields_wrap2"); // wrapper for div containing funds graphs
var selector = $("#timeSelect"); // dropdown graph menu ID
// variables to log subset location in arrays (to use in slice)
var from1 = 0;
var to1 = 10;
var from2 = 0;
var to2 = 10;
var from3 = 0;
var to3 = 10;
var from4 = 0;
var to4 = 10;
var from5 = 0;
var to5 = 10;
var selected = "chart2";
// when the selection is changed in the dropdown menu do:
selector.on("change", function(e) {
// ignore default action for this event
e.preventDefault();
// remove currently displayed graph, 1st child of div (1st graph is 0th)
$(wrapperG.children()[1]).remove();
$(wrapperF.children()[1]).remove();
// get value of currently selected
var selectedVal = $(this).val();
selected = selectedVal;
// check value of selected
// append new graph to wrapper div & run loadGraph to reprocess data
if (selectedVal == "chart2") {
wrapperG.append("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>" + searchData.from + " to " + searchData.to + "</h4><button class='pager' id='previous2' type='button' disabled><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>1-10</button><button class='pager' id='next2' type='button'>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart2 well bs-component'></div></div>").loadGraph(userCitedData.slice(0,10), selectedVal, palette2);
wrapperF.append("<div class='col-lg-6'><h3 class='titles'>Ranked Awarded Funds (£millions)</h3><h4 class='titles'>" + searchData.from + " to " + searchData.to + ", UK only</h4><div class='chart8 well bs-component'></div></div>").loadGraph(userFundedData.slice(0,10), "chart8", palette4);
} else if
... etc ...
});
/*****************************************/
/*********** PAGINATION *****************/
/*****************************************/
// ALL TIME CITED, chart1
// next author set
wrapperG.on("click", "#next1", function (e) {
// ignore default action for this event
e.preventDefault();
// shift pointers up 10 for next subset of array
from1 += 10;
to1 += 10;
// check if at end of data
if (to1 > (allCitedData.length)) {
// remove currently displayed graph, 0th child of div
$(wrapperG.children()[0]).remove();
// load new graph before other graph (0th child of div)
wrapperG.prepend("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>All time (from 1970)</h4><button class='pager' id='previous1' type='button'><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from1+1) + " - " + to1 + "</button><button class='pager' id='next1' type='button' disabled>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart1 well bs-component'></div></div>").loadGraph((allCitedData.slice(from1,to1)), "chart1", palette1);
} else {
// remove currently displayed graph, 0th child of div
$(wrapperG.children()[0]).remove();
// load new graph before other graph (0th child of div)
wrapperG.prepend("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>All time (from 1970)</h4><button class='pager' id='previous1' type='button'><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from1+1) + " - " + to1 + "</button><button class='pager' id='next1' type='button'>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart1 well bs-component'></div></div>").loadGraph((allCitedData.slice(from1,to1)), "chart1", palette1);
}
});
// all time cited, previous author set
wrapperG.on("click", "#previous1", function (e) {
// ignore default action for this event
e.preventDefault();
// shift pointers down 10 for previous subset of array
from1 -= 10;
to1 -= 10;
// check if at start of data
if (from1 == 0) {
// remove currently displayed graph, 0th child of div
$(wrapperG.children()[0]).remove();
// load new graph before other graph (0th child of div)
wrapperG.prepend("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>All time (from 1970)</h4><button class='pager' id='previous1' type='button' disabled><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from1+1) + " - " + to1 + "</button><button class='pager' id='next1' type='button'>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart1 well bs-component'></div></div>").loadGraph((allCitedData.slice(from1,to1)), "chart1", palette1);
} else {
// remove currently displayed graph, 0th child of div
$(wrapperG.children()[0]).remove();
// load new graph before other graph (0th child of div)
wrapperG.prepend("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>All time (from 1970)</h4><button class='pager' id='previous1' type='button'><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from1+1) + " - " + to1 + "</button><button class='pager' id='next1' type='button'>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart1 well bs-component'></div></div>").loadGraph((allCitedData.slice(from1,to1)), "chart1", palette1);
}
});
// OPTIONS CITED, charts 2, 4, 5 & 6
// optional cited, next author set
wrapperG.on("click", "#next2", function (e) {
// ignore default action for this event
e.preventDefault();
// remove currently displayed graph, 1st child of div (1st graph is 0th)
$(wrapperG.children()[1]).remove();
// check selectedVal to see which graph to append
switch(selected) {
case ("chart2"):
// shift pointers up 10 for next subset of array
from2 += 10;
to2 += 10;
// check if at end of data
if (to2 >= (userCitedData.length)) {
// load new graph after other graph (1st child of div)
wrapperG.append("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>" + searchData.from + " to " + searchData.to + "</h4><button class='pager' id='previous2' type='button'><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from2+1) + " - " + to2 + "</button><button class='pager' id='next2' type='button' disabled>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart2 well bs-component'></div></div>").loadGraph((userCitedData.slice(from2,to2)), "chart2", palette2);
} else {
wrapperG.append("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>" + searchData.from + " to " + searchData.to + "</h4><button class='pager' id='previous2' type='button'><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from2+1) + " - " + to2 + "</button><button class='pager' id='next2' type='button'>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart2 well bs-component'></div></div>").loadGraph((userCitedData.slice(from2,to2)), "chart2", palette2);
}
break;
... etc ...
}
});
// optional cited, previous author set
wrapperG.on("click", "#previous2", function (e) {
// ignore default action for this event
e.preventDefault();
// remove currently displayed graph, 1st child of div (1st graph is 0th)
$(wrapperG.children()[1]).remove();
// check selectedVal to see which graph to append
switch(selected) {
case ("chart2"):
// shift pointers down 10 for previous subset of array
from2 -= 10;
to2 -= 10;
// check if at start of data
if (from2 == 0) {
// load new graph after other graph (1st child of div)
wrapperG.append("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>" + searchData.from + " to " + searchData.to + "</h4><button class='pager' id='previous2' type='button' disabled><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from2+1) + " - " + to2 + "</button><button class='pager' id='next2' type='button'>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart2 well bs-component'></div></div>").loadGraph((userCitedData.slice(from2,to2)), "chart2", palette2);
} else {
wrapperG.append("<div class='col-lg-6'><h3 class='titles'>Ranked Author Citations</h3><h4 class='titles'>" + searchData.from + " to " + searchData.to + "</h4><button class='pager' id='previous2' type='button'><span class='glyphicon glyphicon-chevron-left'></span> previous</button><button class='pager indexer' type='button' disabled>" + (from2+1) + " - " + to2 + "</button><button class='pager' id='next2' type='button'>next <span class='glyphicon glyphicon-chevron-right'></span></button><div class='chart2 well bs-component'></div></div>").loadGraph((userCitedData.slice(from2,to2)), "chart2", palette2);
}
break;
case ("chart4"):
... etc ...
}
});
// create array to store various chart names
var fundedCharts = [
"chart7",
"chart8",
"chart9",
"chart10",
"chart11"
];
// Immediately Invoked Function Expression: allows '$' to work with any other plugins
(function ($) {
// add function to '$.fn' object (contains all jQuery object methods)
$.fn.loadGraph = function(graphData, graphSelect, graphColour) {
... creates graph from data ...
} (jQuery));
// bubble chart
(function ($) {
$.fn.loadBubbles = function(graphData, graphSelect) {
... creates bubble chart from data ...
} (jQuery));
// load initial graphs to page, 1st 10 authors
$(".chart1").loadGraph(allCitedData.slice(0,10), "chart1", palette1);
$(".chart2").loadGraph(userCitedData.slice(0,10), "chart2", palette2);
$(".chart3").loadBubbles(valueData, "chart3");
$(".chart7").loadGraph(allFundedData.slice(0,10), "chart7", palette3);
$(".chart8").loadGraph(userFundedData.slice(0,10), "chart8", palette4);
});
我超出了字符限制,因此不得不删除一些代码,但我认为我已经留下了识别问题的重要内容。
基本上,它可以很好地加载包含图表的页面,但如果您尝试使用 #timeSelect
下拉列表加载新图表或使用 #next1
滚动数据,则什么也没有发生了。
如果您需要更多信息,请告诉我 - 谢谢。
** 其他信息 **
我用了https://github.com/laracasts/PHP-Vars-To-Js-Transformer为了将我的数据获取到 View 来加载图表。当您使用它时,它会向 config
发布一个名为 javascript.js
的文件。我已经更改了它以适应我的应用程序,但这可能是我出错的地方。这是我修改后的文件:
javascript.php
(配置)
return [
'bind_js_vars_to_this_view' => 'pages.data',
'js_namespace' => 'Graphs'
];
最佳答案
您发布了很多代码,但没有详细说明失败的原因。无论如何,我的建议是尝试在所有 HTML 代码之后使用 JavaScript 代码,无论是否使用 Blade ,顺序都很重要。因此,您需要确保在执行 javascript 代码之前调用所有库,并且最好在 html 代码已经渲染之后(在页脚末尾)执行所有这些操作。
关于php - jQuery 在 Laravel 5 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32454521/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!