2016-11-23 43 views
1

除電子郵件地址外,一切正常。當我發送電子郵件地址到服務器,只是回聲它,收到什麼。只有@符號問題,休息是好的。

角:

$http({ 
      method: 'POST', 
      url: 'http://______.org/_____.php', 
      data: { 
       signInSubmitBTN: '', email: '[email protected]' 
      } 
     }).success(function (data) { 
      alert(data); //alert empty when [email protected] but joeg.com is ok 
     }); 

PHP

if (isset($_POST['signInSubmitBTN'])) { 

$email = $_POST["email"]; 

echo $email; 
} 

注 -已經配置應用

app.config(function ($httpProvider, $httpParamSerializerJQLikeProvider) { 
    $httpProvider.defaults.transformRequest.unshift($httpParamSerializerJQLikeProvider.$get()); 
    $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'; 
    }) 

回答

3

您需要EN代碼使用Base64:

signInSubmitBTN: '', email: window.btoa('[email protected]') 

而且不要忘了使用atob()

+0

謝謝。另一個問題encodeURIComponent(電子郵件),它是否也可以替代它。 –

+0

看看:http://stackoverflow.com/questions/10267597/url-encode-vs-base64-encoding-usages – deChristo

1

使用此代碼在後端得到POST數據傳回在PHP服務器端進行解碼。

if(isset($_POST)){ 

    $postdata = file_get_contents("php://input"); 

$request = json_decode($postdata); 
    echo $request->email; 
} 
相關問題