我的实际问题是.live()jQuery方法不起作用.
这是我使用它的代码:
jQuery.fn.sb_animateMenuItem = function()
{
var mousehoverColor = '#0089F7';
var duration = 250;
return this.each(function()
{
var originalColor = $(this).css('background-color');
$(this).live('mouseover', function()
{
this.style.cursor = 'pointer';
$(this).animate().stop();
$(this).animate(
{
backgroundColor: mousehoverColor
}, duration);
});
$(this).live('mouseout', function()
{
this.style.cursor = 'default';
$(this).animate(
{
backgroundColor: originalColor
}, duration);
});
});
};
Run Code Online (Sandbox Code Playgroud)
这个snipped用于我的另一个页面:
<script type="text/javascript" src="ui/js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="ui/js/jquery-ui-1.8.1.custom.min.js"></script>
<script type="text/javascript" src="ui/js/color.js"></script>
<script type="text/javascript" src="engine/js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="ui/js/ui.js"></script>
<script type="text/javascript">
// UI effects
$(document).ready(function()
{
$('button').sb_animateButton();
$('input').sb_animateInput();
$('.top_menu_item').sb_animateMenuItem();
$('.top_menu_item_right').sb_animateMenuItem();
$('.left_menu_item').sb_animateMenuItem();
});
</script> …
Run Code Online (Sandbox Code Playgroud) 我在本地服务器上安装了Restler来测试并为我的项目制作一些API.
Api请求通过http://localhost/myproject/api/
.处理.
问题是每次我尝试发出请求时都会收到以下错误:
{
"error": {
"code": 404,
"message": "Not Found"
},
"debug": {
"source": "Routes.php:383 at route stage",
"stages": {
"success": [
"get"
],
"failure": [
"route",
"negotiate",
"message"
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
这也是我的.htaccess
:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api(.*)$ /myproject/api/api.php [QSA,L]
Run Code Online (Sandbox Code Playgroud)
这就是api.php
看起来像:
namespace myproject;
use Luracast\Restler\Restler;
require_once($_SERVER["DOCUMENT_ROOT"]."/myproject/resources/engine/settings.php");
require_once(Settings\Path\Absolute::$library."/restler/vendor/restler.php");
$restler = new Restler();
$restler->addAPIClass("myproject\\User");
$restler->handle();
Run Code Online (Sandbox Code Playgroud)
我猜周围有一些误配,但我真的无法弄清楚出了什么问题.
(我也在Stackoverflow上尝试了一些解决方案,但它们似乎对我不起作用)
编辑:
我尝试使用以下路径到达示例 http://localhost/myproject/resources/engine/library/restler/public/examples
并且它们正在工作,所以我想它与Restler本身的配置有关,因为它似乎无法工作http://localhost/myproject/api
.
此外,我还尝试复制Restler Explorer http://localhost/myproject/api/explorer
,我一直收到错误: …
我正在尝试构建AJAX登录系统,但PHP会话存在一些问题。
这是我在我使用的AJAX代码index.php
:
$("#buttonLogin").click(function(){
$.post("<?php echo $AJAX ?>/ajaxLogin.php",{
Username : $("#loginUsername").val(),
Password : $("#loginPassword").val()
},
function(result){
if(result == "OK"){
window.location.href = "<?php echo $PUBLIC?>/home.php";
} else {
$("#loginMessageError").show();
}
});
});
Run Code Online (Sandbox Code Playgroud)
这就是ajaxLogin.php
通过AJAX调用的:
<?php
require_once("../settings.php");
require_once($ABS_ENGINE."/classUser.php");
$user = new User();
if($user->loginUser($_POST["Username"], $_POST["Password"])){
$UserID = $user->getUserId($_POST["Username"]);
session_start();
$_SESSION['UserID'] = $UserID;
echo "OK";
} else {
echo "ERROR";
}
?>
Run Code Online (Sandbox Code Playgroud)
当我进入home.php
并尝试echo时$_SESSION["UserID"]
,出现以下错误:
注意:未定义的索引:第23行的C:\ xampp \ htdocs \ webname \ resources \ templates \ headerHome.php中的UserID
这可能是不正确的,因为必须在任何输出之前设置会话,但是如果我尝试回显$_SESSION['UserID'] = …
我正在使用ajax请求向DB发送注释.成功的反应标志着
1. OK
Run Code Online (Sandbox Code Playgroud)
问题实际上是来自php脚本的响应
1.
2. OK
Run Code Online (Sandbox Code Playgroud)
所以我调试了脚本并注意到当脚本执行以下行时添加了换行符:
require_once($ABS_APPS."/quotes/classQuote.php");
Run Code Online (Sandbox Code Playgroud)
经过一些搜索后,我读到它可能是BOM(字节顺序标记)问题.所以我只是classQuote.php
用十六进制编辑器下载并打开文件,注意到没有BOM ...有人可以帮我吗?
PS我的项目中的所有文件都包含在UTF-8中,我目前是usint NetBeans,它不会将BOM添加到文件中.
这是有罪的脚本:
// Send new comment to DB
case "send":
$notification = new Notification();
if($comment->insert($_POST["username"], $_POST["comment"], $_POST["app"], $_POST["entryId"])){
switch ($_POST["app"]) {
case "quotes":
require_once($ABS_APPS."/quotes/classQuote.php");
$quote = new Quote();
$quoteData = $quote->get($_POST["entryId"]);
// If user comments his own entry we don't have to send the notification
if($quoteData["UserAuthor"] != $_SESSION["User"]){
$notification->newComment($_POST["username"], $quoteData["UserAuthor"], $_POST["entryId"], $_POST["app"]);
}
break;
default:
break;
}
echo "OK";
} else {
echo "ERROR";
}
break;
Run Code Online (Sandbox Code Playgroud) 正如标题所说,有一种@include()
情况会导致Apache在执行时崩溃.
这是有罪的代码,位于profile.php
:
<hr>
@include('sections/userInformations', array('userOwner' => $profileUser, 'userVisitor' => $user))
<hr>
Run Code Online (Sandbox Code Playgroud)
在$profileUser
和$user
来自PagesController.php
:
public function getProfile($username) {
return View::make('profile', array(
'privacy' => Privacy::where('user', '=', $username)->first(),
'profileUser' => User::where('username', '=', $username)->first(),
'user' => Auth::user()
));
}
Run Code Online (Sandbox Code Playgroud)
Apache error.log
:
[Thu Apr 17 18:17:30.840838 2014] [mpm_winnt:notice] [pid 2536:tid 324] AH00428: Parent: child process 1716 exited with status 3221225725 -- Restarting.
[Thu Apr 17 18:17:31.146862 2014] [ssl:warn] [pid 2536:tid 324] AH01909: RSA certificate configured …
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个按钮,允许我平台的用户提交一个帖子,或者如果再次按下该按钮则删除之前的投票.
问题是当用户第二次点击按钮时,在投票后没有任何反应.
这是管理按钮行为的代码:
if($(".timeline-action-plus").hasClass("btn-success")) {
$(".timeline-action-plus").click(function(){
rating.removeVote($(this).data("entry-id"), $(this).data("token"));
});
} else {
$(".timeline-action-plus").click(function(){
rating.votePlus($(this).data("entry-id"), $(this).data("token"));
});
}
Run Code Online (Sandbox Code Playgroud)
该removeVote
和votePlus
功能还需要修改按钮的方面的护理:
function votePlus(id,token){
$.post(
"http://localhost/user/vote",
{
rating : '1',
entryID : id,
_token : token
},
function(result) {
if(result === "OK"){
$(".timeline-action-plus[data-entry-id=" + id + "]").removeClass("btn-default");
$(".timeline-action-plus[data-entry-id=" + id + "]").addClass("btn-success");
}
}
);
}
function removeVote(id, token) {
$.post(
"http://localhost/user/removeVote",
{
entryID : id,
_token : token
},
function(result) {
if(result === "OK") {
$(".timeline-action-plus[data-entry-id=" + id + …
Run Code Online (Sandbox Code Playgroud) 在我正在开发的平台中,可以通过向api/company/{id}
API 端点发送 GET 请求来请求用户的公司数据。
默认情况下,id
参数是一个整数,但通常也可以将其设置为字符串:api/company/mine
将检索经过身份验证的用户的公司数据。
为了实现这一点,我创建了一个中间件来拦截 API 调用并替换mine
为实际的公司 ID。不幸的是,我的解决方案并不完全符合我的想法。
这是我目前的解决方案:
$request->merge([
'id' => $request->user()->company
]);
Run Code Online (Sandbox Code Playgroud)
这是通过将 id 添加到请求的输入中来实现的,以便以后可以使用 访问它$request->input('id');
,但问题是,如果我尝试访问,$request->route('id')
我仍然会得到旧值。
是否可以直接更改路由参数?
聚苯乙烯
我想到的另一个解决方案是实际以编程方式使用新参数创建一个新请求,然后将该请求传递给next()
中间件中的函数。
如何在PHP中生成渐进式顺序唯一ID?
例如,订单应为:
aaaaaa <aaaaab <aaaaac等...
我想要实现的是3D翻转文本中的单个字母.
<h1>WebN<span class="text-muted" id="logo-alpha">α</span>me</h1>
Run Code Online (Sandbox Code Playgroud)
在这种特殊情况下,我希望在用鼠标悬停时水平翻转α.
我尝试通过将α放在外面div
并且工作正常来做同样的事情,但是当我尝试对span
内部做同样的事情时它不会h1
.
这是我的CSS:
#logo-alpha {
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
transform: rotateY(0deg);
}
#logo-alpha:hover {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
transform: rotateY(180deg);
}
Run Code Online (Sandbox Code Playgroud) 我只是想知道是否可以同时发送GET和POST AJAX请求,以及它是如何使用该XMLHttpRequest
对象进行的.
谢谢大家的帮助:D
我遇到以下代码的问题:
/*
* Esercizio 5
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* getProduct(char product[]);
long getNumber(char product[]);
int main(int argc, char** argv) {
char product1[60] = {0};
char product2[60] = {0};
char product3[60] = {0};
char productInput[60] = {0};
int flag = 0;
long cost = 0;
printf("Product 1: ");
gets(product1);
printf("Product 2: ");
gets(product2);
printf("Product 3: ");
gets(product3);
do {
printf("Product and quantity: ");
gets(productInput);
printf("productInput: %s\n", getProduct(productInput));
printf("product1: %s\n", getProduct(product1));
if(getProduct(product1) == getProduct(productInput)){ /* PROBLEM HERE!!! */ …
Run Code Online (Sandbox Code Playgroud) 我正在按照本教程:http://net.tutsplus.com/tutorials/javascript-ajax/uploading-files-with-ajax/comment-page-1/#comments了解如何通过ajax上传多个文件.
这是我的HTML:
<form class="form-horizontal" id="settingsChangeAvatar" method="post" enctype="multipart/form-data" action="<?php echo $AJAX."/ajaxUpload.php"?>">
<input class="input-xlarge input-file" id="settingsUploadAvatar" name="settingsUploadAvatar" type="file" multiple />
<button class="btn" id="uploadAvatarButton" type="submit">Upload</button>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的ajaxUpload.php:
foreach($_FILES["settingsUploadAvatar"]["error"] as $key => $error){
if($error == UPLOAD_ERR_OK) {
$name = $_FILES["settingsUploadAvatar"]["name"][$key];
move_uploaded_file($_FILES["settingsUploadAvatar"]["tmp_name"][$key], $_SERVER["DOCUMENT_ROOT"]."/webname/".$_FILES["settingsUploadAvatar"]["name"][$key]);
}
}
echo("File uploaded");
Run Code Online (Sandbox Code Playgroud)
我的代码应与教程中的代码相同.谢谢你的帮助.
有人能告诉我为什么这个case 1
被完全忽略了吗?
// #define M 50 is at the top
char product[M] = {0};
int choice = -1;
printf("Command: ");
scanf("%d", &choice);
switch(choice){
case 0:
break;
case 1:
printf("Product: ");
gets(product);
insert_product(warehouse, price, product);
break;
case 2:
// print_all();
break;
default:
printf("Scelta non valida\n");
break;
}
Run Code Online (Sandbox Code Playgroud)