小编Dar*_*ber的帖子

如何在TR和TD中添加属性?

我想使用数据数据表添加行,我可以这样做

var table = $('#mytable').DataTable();
table.add.row(['first column', 'second column', 'three column', 'etc']);
Run Code Online (Sandbox Code Playgroud)

我需要的是这样的东西(TR和TD标签中的一些属性)

<tr id="someID">
<td>first column</td>
<td>second column</td>
<td>three column</td>
<td id="otherID">etc</td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我如何用数据表做到这一点?

datatables

26
推荐指数
1
解决办法
4万
查看次数

模式重写; 在URL的末尾有/不带尾部斜杠?

我基本上尝试过下面的mode_rewrite规则.它最后使用斜杠,但是我想让它工作,无论它是否有一个尾部斜杠.基本上我希望它像这样,因为有些人认为它是正常的,最后有一个斜线而其他人不这样做,因此我希望它能够工作,无论它是否存在.

RewriteRule ^signup/register(.[^/]*) /signup/register.php [NC]
Run Code Online (Sandbox Code Playgroud)

基本上它会工作,http://localhost/signup/register/但如果我从最后删除/它会给出404错误.

.htaccess mod-rewrite friendly-url url-rewriting

9
推荐指数
3
解决办法
4万
查看次数

Python使用lxml xpath从input元素获取值

我想要paypal cURL登录,所以我需要auth值.我尝试使用此python代码从html源获取auth值

import requests
import lxml.html
import StringIO
from xml.etree.ElementTree import ElementTree
r = requests.get("https://paypal.com/cgi-bin/webscr?cmd=_login-run")
login_page = r.text.encode('utf-8') #printing html source
html = lxml.html.fromstring(login_page) #printing <Element html at 0x7f19cb242e$
auth = html.xpath('//input[@name="auth"]') #printing [<InputElement 7fb0971e9f1$
print auth
Run Code Online (Sandbox Code Playgroud)

但是上面的代码打印了这个[<InputElement 7fb0971e9f18 name='auth' type='hidden'>],那么我如何通过解码获得auth值&#x2d; &#x2d; &#x2e;?输入部分看起来像这样

<input name="auth" type="hidden" value="ADPifNsidn&#x2d;P0G6WmiMMeJbjEhnhIvZCNg7Fk11NUxc0DyYWzrH&#x2d;xk5ydV&#x2e;85WCzy">
Run Code Online (Sandbox Code Playgroud)

非常感谢你.

python xpath paypal

5
推荐指数
1
解决办法
5251
查看次数

带有请求的 Python 登录贝宝

我想在成功登录贝宝后打印仪表板 html 源代码,这是我的完整代码

import requests
import lxml.html

# Get Auth & Login URL
get_login = requests.get('https://paypal.com/cgi-bin/webscr?cmd=_login-run')
get_login_response = get_login.text.encode('utf-8') #printing html source
get_login_html = lxml.html.fromstring(get_login_response) #printing <Element html at 0x7f19cb242ec0>
auth = get_login_html.xpath("//input[@name='auth']/@value") #printing [<InputElement 7fb0971e9f18 name='auth' type='hidden'>]
login_url = get_login_html.xpath("//form[@name='login_form']/@action")

# Post Login
payload = {
'login_cmd':'',
'login_params':'',
'login_email':'websec@spam4.me',
'login_password':'jancok666',
'auth':auth[0],
'submit.x':'Log In',
'form_charset':'UTF-8',
'browser_name':'Firefox',
'browser_version':'18',
'browser_version_full':'18.0'
}
post_login = requests.post(login_url[0], data=payload)
post_login_response = post_login.text.encode('utf-8')

print post_login_response
Run Code Online (Sandbox Code Playgroud)

但我得到的是像这样的验证码挑战的 html 源代码

......... <h1 class="headerText">Security Challenge</h1><p>Type the characters you see in …
Run Code Online (Sandbox Code Playgroud)

python paypal python-requests

5
推荐指数
1
解决办法
2133
查看次数

如何在 Laravel 5.2 中扩展验证表单请求?

我有这个验证请求

<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class CreateUserRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
          'email' => 'required|email|unique:users',
          'password' => 'required|confirmed|min:6',
          'full_name' => 'required',
          'address' => 'required',
          'phone' => 'required|numeric',
          'family_name' => 'required',
          'family_address' => 'required',
          'family_phone' => …
Run Code Online (Sandbox Code Playgroud)

php laravel

5
推荐指数
1
解决办法
3689
查看次数

会话在 Laravel API 中不起作用

通常,我在使用网站(非 API)时会在会话内保存临时数据/数组。

今天我想用 Laravel API 做同样的事情(在会话中保存临时数据/数组)。

这是我的路线。

Route::middleware(['auth:api', 'isMember'])->group(function () {

  Route::get('createSession', function (){
    $a = Session::put('example', 'this is example session.');
    return "session created";
  });

  Route::get('getSession', function () {
    return Session::get('example');
  });

});
Run Code Online (Sandbox Code Playgroud)

当我访问/api/createSession它时返回session created,但是当我访问/api/getSession它时什么也不返回。

那么如何在 API 中使用会话呢?

我认为为什么这不起作用,因为 API 使用基于令牌的身份验证而不是基于会话的身份验证,请参阅config/auth.php身份验证防护部分。

如果在 API 内部使用会话被认为是不好的做法,那么您对在 API 内部保存临时数据/数组以进行共享托管有何建议?

到目前为止我所尝试的是保存数据/数组,Storage::disk(local)但我认为这不是最佳实践。

提前致谢。

PS:我将使用Session来存储有关Cart的临时数据

laravel-5

5
推荐指数
1
解决办法
1万
查看次数

Laravel 5.2:WhereHas中的未定义变量

undefined variable $jenis_mobil完全上$q->where('name', $jenis_mobil->name)

    $jenis_mobil = Car_class::find($request->jenis_mobil);
    $dari_kota = City::find($request->dari_kota);       

    $vehicles = Vehicle::whereHas('car', function($q){
        $q->whereHas('car_class', function($q){
            $q->where('name', $jenis_mobil->name);
        });
    })
    ->whereHas('partner', function($q) {
        $q->whereHas('kota_pool', function($q){
            $q->where('name', $dari_kota->name);
        });
    })
    ->where('year', $request->tahun_mobil)
    ->get();
Run Code Online (Sandbox Code Playgroud)

我的代码有问题吗?我认为是因为$jenis_mobil没有传递给whereHas

laravel

4
推荐指数
1
解决办法
379
查看次数

AngularJS $ http导致两次请求?

这是我的JS

var rentalkika = angular.module('rentalkika', ['ngRoute']);
rentalkika.config(function ($routeProvider) {
    $routeProvider
    .when('/', {
        templateUrl : 'pages/main.html' 
    })
    .when('/sewa_mobil', {
        templateUrl : 'pages/sewa_mobil.html',
        controller : 'FilterController' 
    })
    .when('/contact', {
        templateUrl : 'pages/contact.html',
        controller : 'ContactController'
    })
    .when('/register', {
        templateUrl : 'pages/register.html'
    });

});

rentalkika.controller('ContactController', function ($scope, $http) {
    var config = {
        headers: { 'X-Parse-Application-Id' : 'secret' }    
    };


    $http.get('http://128.199.249.233:1337/parse/classes/vehicle', config).then(function (response){
        console.log(response.data.results);
    }, function (error) {
        console.log(response);
    });


});
Run Code Online (Sandbox Code Playgroud)

这是我的 contact.html

<div>
tes about html
</div>
Run Code Online (Sandbox Code Playgroud)

当我去localhost:3000/#/contact检查网络部分中的chrome时,它会在http://128.199.249.233:1337/parse/classes/vehicle第一次返回 …

angularjs

4
推荐指数
1
解决办法
118
查看次数

Laravel如何更新一对一关系?

条款表:

  • term_id
  • 名称
  • ug

Term_taxonomy表:

  • term_taxonomy_id
  • term_id
  • 描述

我的学期模型:

public function TermTaxonomy(){
    return $this->hasOne('TermTaxonomy');
}
Run Code Online (Sandbox Code Playgroud)

我的TermTaxonomy模型:

public function Term(){
    return $this->belongsTo('Term');
}
Run Code Online (Sandbox Code Playgroud)

我的类别控制器:

public function update($id){
    echo "$id"; // echo success
    echo $data['name']; // it should update name field in term table
    echo $data['slug']; // it should update slug field in term table
    echo $data['TermTaxonomy']['description']; // it should update description field in termtaxonomy table
}
Run Code Online (Sandbox Code Playgroud)

如何更新一对一关系?也许与push()

谢谢,对不起,我是新来的laravel。

php class laravel laravel-4

3
推荐指数
2
解决办法
7388
查看次数

如何使用Vee Validate检查验证是否通过?

我有多步骤表格。每个步骤都有其自己的验证,每个步骤都有一个“下一步”按钮。

我想检查每当单击下一步按钮时,表单是否通过验证,如果验证失败,请阻止进行下一步。

这是我的表格

<form method="post">
  <div id="step1" v-show="step == 1">  
    <div class="form-group" :class="{'has-error': errors.has('startDate') }">
      <label for="startDate">Start Date</label>
      <input type="text" name="startDate" class="form-control" id="startDate" v-validate="'required'">
      <span v-show="errors.has('startDate')" class="text-danger">@{{ errors.first('startDate') }}</span>
    </div>
    <div class="form-group" :class="{'has-error': errors.has('adDuration') }">
      <label for="">Ad Duration</label>
      <select class="form-control" name="adDuration" v-on:change="total" v-model="adDetailOrder.unit" v-validate="'required'">
        <option v-for="adDuration in adDurations" :value="adDuration.unit">@{{ adDuration.text }}</option>
      </select>
      <span v-show="errors.has('adDuration')" class="text-danger">@{{ errors.first('adDuration') }}</span>
    </div>
  </div>

  <div id="step2" v-show="step == 2">
    //input form and v-validate goes here
  </div>

  <div id="step3" v-show="step == 3">
    //input form and v-validate …
Run Code Online (Sandbox Code Playgroud)

vue.js

3
推荐指数
1
解决办法
4749
查看次数