开发者

jquery: show data after change event

i have this code:

<script>
$("#mod").change(function() {
 var matches=str.match(/(EE|[EJU]).*(D)/i);
         $.ajax({
                  type="post",
                  url="process.php",
                  data="matches",
                  cache=false,
             开发者_C百科     async=false,
                  success= function(res){
                         $('#rslt').replaceWith("<div id='value'><h6>Tuner range is" + res + " .</h6></div>");
                         return this;
                 }
         });
   return false;
});
 </script>

i want this code can show the result normally..where is my fault?


remove the returns

and format as ( : instead of = )

         $.ajax({
                  type:"post",
                  url:"process.php",
                  data:"matches=" + matches,
                  cache:false,
                  async:false,
                  success: function(res){
                         $('#rslt').replaceWith("<div id='value'><h6>Tuner range is" + res + " .</h6></div>");
                         // return this; <<--- remove that too...
                 }
         })

and if you want matches to be passed as data use data:"matches=" + matches,...

and $_POST['matches'] is the way to get the value via PHP


<script>
$("#mod").change(function() {
 var matches=str.match(/(EE|[EJU]).*(D)/i);
         $.ajax({
                  type:"post",
                  url:"process.php",
                  data:"matches="+matches,
                  cache:false,
                  async:false,
                  success: function(res){
                         $('#rslt').replaceWith("<div id='value'><h6>Tuner range is" + res + " .</h6></div>");

                   }
         });
  });
 </script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜