我们正在为我们的应用程序创建一个 REST API。
网页.php
Route::post('add-new-student', 'StudentController@addNewStudent');
Run Code Online (Sandbox Code Playgroud)
学生控制器.php
Route::post('add-new-student', 'StudentController@addNewStudent');
Run Code Online (Sandbox Code Playgroud)
现在,当我们发送 JSON 响应时,如果出现错误,它不会转到 else 块,而是在邮递员中显示 404 页面。
我们不知道自己做错了什么!
笔记
我有一个简单的函数,它有两个参数,一个用于图像URL,另一个用于图像的属性
function image_found($url,$attributes)
{
if(@getimagesize($url))
{
echo '<img src="'.$url.'" '.$attributes.'/>';
}
else
{
echo '<img src="'.base_url().'/site_images/image_not_found.svg" '.$attributes.'/>';
}
}
Run Code Online (Sandbox Code Playgroud)
现在我要做的是创建一个可点击的图像,如果找到图像,现在这是html代码
echo '<div class="panel-body">';
echo '<div class="col-md-12 col-lg-12 col-sm-12 text-center">';
$url = base_url().'product_images/'.$result->product_image.'.'.$result->image_type;
$attributes = 'height="200px" width="100%"';
echo '<a href="product.com/full/url">'.image_found($url,$attributes).'</a>';
echo '</div>';
echo '</div>';
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出
<div class="panel-body">
<div class="col-md-12 col-lg-12 col-sm-12 text-center">
<img src="http://localhost/nsc/product_images/7908076366784972032090.jpg" height="200px" width="100%"/>
<a href="#"></a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我不知道这里有什么问题,我正在使用bootstrap
Your view folder path does not appear to be set correctly. Please open the following file and correct this: index.php我收到这个错误,我不知道有什么问题,我从官方网站下载了rc3(发布候选人3),解压缩它,添加了资产文件夹和帮助,当我运行应用程序时,我收到了错误Your view folder path does not appear to be set correctly. Please open the following file and correct this: index.php,这是我的index.php文件代码,图像显示了文件夹结构
// index.php code
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的数据表
<datalist id="properties">
<option value="property name"></option>
<option value="property"></option>
</datalist>
Run Code Online (Sandbox Code Playgroud)
现在,我正在使用此代码查找用户输入的值在列表中的位置:
var user_property = $('#user_property').val().toLowerCase(); // taken from input type with id user_property
var pro = $('#properties').find("option[value="+user_property.replace(' ','-')+"]");
if(pro != null && pro.length > 0)
{
// run some code
}
else
{
// show error popup
}
Run Code Online (Sandbox Code Playgroud)
我收到了错误 var pro = $('#properties').find("option[value="+user_property.replace(' ','-')+"]");
错误代码说 Syntax error, unrecognized expression: option[value=property name]
如何摆脱这个错误?
php ×3
codeigniter ×1
datalist ×1
html ×1
javascript ×1
jquery ×1
laravel ×1
rest ×1
validation ×1