簡體   English   中英

帶有Angular的Sweet Alert HTTP請求不起作用

[英]Sweet Alert http request with Angular doesn't work

我正在用Sweet Alert創建一個表單,並且在swal函數內部有一個post請求,但是當我點擊Submit時,什么也沒發生。 希望能有所幫助。

$scope.formModal = function(){
swal({background:'#ACF1F4',html:"<form method='post' id='loginform'>Username:
<input id='username' name='username' >
<br><br>Password:<input type='password' id='password' name='password'><br>  <br></form>",
confirmButtonText: 'Submit',showCancelButton: true}
, function(){
$http.post("login.php",{"username":username,"password":password})
.success(function(data){swal(data)})
}
);

}

這里有多個問題:

  1. 您不能以這種方式將字符串分成多行。
  2. swal通話結束時錯過了')'
  3. 您缺少title參數,對於swal是必填的
  4. HTML必須接收一個布爾值,指示您的消息包含HTML代碼

我不太確定是否可以在SweetAlert中創建表單,至少在他們的頁面中沒有示例。

swal({background:'#ACF1F4', html:true, title:"<form method='post' id='loginform'>Username: <input id='username' name='username' style='width: 100%' ><br><br>Password:<input type='password' id='password' name='password'><br>  <br></form>",
confirmButtonText: 'Submit',showCancelButton: true})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM