iT邦幫忙

0

alert物件如何只顯示文字

  • 分享至 

  • twitterImage

r_wr.php部分

//因為要打中文所以加入html
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 if($resultt){
  echo $arr="重複填寫";          	           	
     	}
 else{
 
 echo "可以了";
 
 }

ajax部分
alert(data)會顯示html語法,要如何只顯示echo 中文
若用先在r_wr.php 用數字 再到ajax用數字判斷 顯示alert 也可以
但請問還有甚麼方法嗎?
謝謝

$.ajax({
    type: "POST",
    url: "r_wr.php",
    async:false,
    data: decodeURIComponent($('#f2').serialize(),true),    
    dataType: "text",
    error: function(jqXHR, textStatus, errorThrown) {
    alert(jqXHR.responseText);
    },
    success: function(data) {          
        alert(data);
        window.location.reload();          
    }
   
});

echochio iT邦高手 1 級 ‧ 2019-11-07 20:07:54 檢舉
還以為隱藏HTML 程式碼.....好像沒辦法吧..
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
1
firecold
iT邦新手 1 級 ‧ 2019-11-07 17:47:25
r_wr.php
$result ? 1 : null;

echo $result;
-------------------------------------
$.ajax({
    type: "POST",
    url: "r_wr.php",
    async:false,
    data: decodeURIComponent($('#f2').serialize(),true),    
    dataType: "text",
    error: function(jqXHR, textStatus, errorThrown) {
    alert(jqXHR.responseText);
    },
    success: function(data) {          
        if(data == 1){
            alert('重複填寫');
        }else{
            alert('可以了');
        }
        window.location.reload();          
    }
   
});

其實很多種作法
不過最快就這樣

然後你的標題跟問題其實差蠻多的....

看更多先前的回應...收起先前的回應...
Zed_Yang iT邦新手 3 級 ‧ 2019-11-07 17:59:44 檢舉

真實標題
alert物件如何只顯示文字
/images/emoticon/emoticon30.gif

dragonH iT邦超人 5 級 ‧ 2019-11-07 18:25:22 檢舉

$data == 1

是多了一個 $

小魚 iT邦大師 1 級 ‧ 2019-11-07 21:45:56 檢舉

當成PHP在寫了?

firecold iT邦新手 1 級 ‧ 2019-11-08 10:16:08 檢舉

完全阿 感謝各位大大指正

0

你犯的問題,跟你所理解的問題還有題目。
完全搭不上邊的。

你只是單純的後端跟前端語言分不清楚而已。
這解釋起來有太多說不清楚了。那就明天解釋吧。

mayyola iT邦研究生 2 級 ‧ 2019-11-09 09:03:21 檢舉

嗯嗯,因為不塞html,我用Microsoft expression開網頁中文會變亂碼..但ajax 回傳給alert時,會連html語言也顯示出來..

<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
0
阿展展展
iT邦好手 1 級 ‧ 2019-11-09 04:28:06

PHP是一種開源的通用電腦手稿語言,尤其適用於網路開發並可嵌入HTML中使用。

HTML 超文本標記語言是一種用於建立網頁的標準標記語言。HTML是一種基礎技術,常與CSS、JavaScript一起被眾多網站用於設計網頁、網頁應用程式以及行動應用程式的使用者介面。

這...這兩個不太一樣哦....

mayyola iT邦研究生 2 級 ‧ 2019-11-09 09:04:25 檢舉

嗯..這我有點了解..不過跟實際操作又會有些不懂的地方..

我要發表回答

立即登入回答