0

からデータを受け取りたいこのコード$.post("re.asp。それ、どうやったら出来るの?

<script type='text/javascript'>
 $(function () {
  $("#pasteable").bind('paste', function (event) {
    var $pastable = $(this);
    $.post("re.asp",{ste:pastable},function(){
    setTimeout(function () {
        $("#target").html($pastable.val());
        $pastable.focus();
    }, 100);
  });});
 });
 </script>
 Paste here: <input id="pasteable" />
 <span id="target"></span>
4

5 に答える 5

0

これはあなたがからデータを受け取る方法です$.post()

$.post("URL", {name1:val1, name2:val2}, function(data) {
  alert(data);
});

コールバックでは、URL ページの結果を保持する変数を渡す必要があります。

あなたの場合

 $.post("re.asp",{ste:pastable},function(data){
    alert(data);  // data has the result of re.asp
 });
于 2013-05-29T04:13:02.553 に答える
0

これを試して:-

$(function () {
   $("#pasteable").bind('paste', function (event) {
   var $pastable = $(this);
   $.post("re.asp",{ste:pastable},function(data){
    alert(data);    //it will return your data(from re.asp) you can fetch from here
  });
 });
于 2013-05-29T04:13:37.540 に答える
0
 I can do it but i want to use this function **setTimeout(function () {
$("#target").html($pastable.val());
$pastable.focus();
}, 100); *too $.post i try but still error pastable undefined***
    <script type='text/javascript'>
   $(function () {
   $("#pasteable").bind('paste', function (event) {
    var $pastable = $(this);
    $.post("re.asp",{ste:pastable},function(){
     setTimeout(function () {
    $("#target").html($pastable.val());
    $pastable.focus();
    }, 100);
  });});
 });
  </script>
 Paste here: <input id="pasteable" />
  <span id="target"></span>
于 2013-05-29T04:25:23.247 に答える
0

まず、jQuery を使用することをお勧めします。むしろ$。プロジェクトがどれだけ大きくなるかに応じて、健全性のために $ 記号を含む変数を使用する場合、ここでは setTimeout は必要ありません。ローカル変数に割り当てる代わりに、パフォーマンスの低下やセレクターの使いすぎに気付かない。

<script type='text/javascript'>
 $(function () {
  $("#pasteable").bind('paste', function (event) {
    pastable = $(this);
    $.post("re.asp",{ste:pastable},function(data){
        //data variable is your response from re.asp
        $("#target").html(pastable.val());
        pastable.focus();

    });
  });
 });
 </script>
 Paste here: <input id="pasteable" />
 <span id="target"></span>

json、html、xmlなどを探している場合は、次のように指定します

$.post('',{},function(data){},  'json');

function(data){} ' data ' は応答です。これが役立つことを願っています。

于 2013-05-29T04:26:58.080 に答える
-1

ドキュメントを読むだけ...

$.post("test.php", { name: "John", time: "2pm" })
.done(function(data) {
  alert("Data Loaded: " + data);
});

この情報の使い方を知っていただければ幸いです。

于 2013-05-29T04:12:45.457 に答える