//新增動作
public function addUser(Request $request)
{
$data = $request -> param();
$status = 1;
$message = '新增成功';
$rule = [
'name|使用者名稱' => "require|min:3|max:10",
; "require|min:3|max:10",
'email|信箱' => 'require|email'
];
$result = $this -> validate( $data, $rule);
//return ['status'=>$status, 'message'=> $result ];
## if ($result === true) {
// return ['status'=>$status, 'message'=>$request->param()];
$user= UserModel::create($request->param() );
# if ($user === null) {
$status = 0 100 如果# }
return ['status'=>$status, 'message'=>$message];
}
#
你的 return ['status'=>$status, 'message'=>$message]; 。不是應該用assign()嗎。還有目測是資料型態錯誤。把你的資料變數例如$data加個[0]。 。 。 $data[0]輸出看看
[0] InvalidArgumentException in Response.php line 316
##變數型別錯誤: array { if (null == $this->content) { $content = $this->output($this->data);if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ '__toString ', ]) ) {
## ) 錯誤中與變數 } $this->content = (string) $content; } return $this->content; } /** * 取得狀態碼Call Stack
in Response.php line 316
at Response-> ;Response.php 第94 行中的getContent()at start.php 第19 行中的Response->send()at require('D:\php\tp5\ thinkphp\. ..') 在index.php第17行環境變數GET資料/index/user/adduser_htmlPOST數據空白檔案空白Cookiesthinkphp_show_page_trace0|0# PHPSESSID##伺服器/請求資料
PATH
C:\Windows\system32;C :\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C: \Program Files\Common Files\Intel \WirelessCommon\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\
SYSTEMROOT
#C:\Windows
COMSPEC
C:\Windows\system32\cmd.exe
PATHEXT
.COM;.EXE;.BAT; .CMD;.VBS;.VBE ;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR
C:\Windows
PHP_FCGI_MAX_REQUESTS
1000
PHPRC
C:/myphp_www/PHPTutorial/php/php-5.6.27-nts/
_FCGI_SHUTDOWN_EVENT_
#1796
#_FCGI_SHUTDOWN_EVENT_#1796##_FCGI_SHUTDOWN_EVENT_
1796
SCRIPT_NAME
/index.php
REQUEST_URI
/index/user/adduser.html
QUERY_STRING
/index /user/adduser.html
REQUEST_METHOD
GET
SERVER_PROTOCOL
HTTP/1.1
#GATEWAY_INTERFACE
#CGI /1.1
REDIRECT_QUERY_STRING
/index/user/adduser.html
REDIRECT_URL
/index/user/adduser.html
# REMOTE_PORT
51873
SCRIPT_FILENAME
D:/php/tp5/public/index.php
##SERVER_ADMINadmin@php。 cnCONTEXT_DOCUMENT_ROOTD:/php/tp5/publicCONTEXT_PREFIXREQUEST_SCHEMEhttp##DOCUMENT_ROOT
D:/php/tp5/public
REMOTE_ADDR
#127.0.0.1
SERVER_PORT
#80
# SERVER_ADDR
127.0.0.1
SERVER_NAME
www.tp5.cn
SERVER_SOFTWARE
Apache/2.4.23 (Win32) OpenSSL /1.0.2j mod_fcgid/2.3.9
SERVER_SIGNATURE
SystemRoot
C:\Windows
#HTTP_COOKIE
thinkphp_show_page_trace=
##HTTP_COOKIEthinkphp_show_page_trace=0| 0; PHPSESSID=b1e4csbk4p7etj8p50l4m9r0r6; thinkphp_show_page_trace=0|0HTTP_ACCEPT_LANGUAGEzh-CN,zh;q=0.9HTTP_ACCEPT_ENCODINGgzip, deflate##HTTP_ACCEPT_ENCODING##gzip, deflate##Pm#PM
文字/html,應用程式/xhtml+xml,應用程式/xml;q=0.9,圖片/webp,圖片/apng,*/*;q=0.8
HTTP_USER_AGENT
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36(KHTML,如Gecko) Chrome/67.0.3396.99 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS
#111414 月closeHTTP_HOSTwww.tp5.cnREDIRECT_STATUS#200#FCGI_ROLE#回應者PHP_SELF/index.phpREQUEST_TIME_FLOAT1531301786.1009#REQUEST_TIME1531301786PATH_INFO/index/user/adduser.html環境變數空白ThinkPHP常數#APP_PATH##D:\php\tp5\runtime \log\
CACHE_PATH
D:\php\tp5\runtime\cache\
TEMP_PATH
D:\php\tp5\runtime\temp \
CONF_PATH
D:\php\tp5\public/../application/
CONF_EXT
.php
#ENV_PREFIX
PHP_
IS_CLI
false
IS_WIN
true
USER_ID
#1
ThinkPHP V5.0.20 { 十年磨一劍-為API開發設計的效能框架 }
0.103005s
沒有報錯嗎?你這個是ajax 返回,沒反應的話 F12看看錯誤訊息