AJAX PHP 循环之后点击状态更换图片,该如何解决

WBOY
Release: 2016-06-13 11:48:37
Original
800 people have browsed it

AJAX PHP 循环之后点击状态更换图片
                   foreach ( $account as $key => $value)
         {
    ?> 
 
          
        ');">
          AJAX PHP 循环之后点击状态更换图片,该如何解决 
        

                  }
        else{
        ?>
        ');">
          AJAX PHP 循环之后点击状态更换图片,该如何解决 
        

            
        



function xingxing(id,name){
       $.ajax({
          type: "POST",
          url: "",
          processData: "false",
          data: "n=" + Math.random() + "&fn=" + escape(id) + "&starflag=" + escape(name) + "",
          success: function(msg){
            var msg = $.trim(msg);
            switch (msg){
              case "200":
                 location.replace(location.href);
              case "110":  //重新登录
                location.replace(location.href);
              case "120":  //修改密码
                location.replace(location.href);
                break;
              default:
                alert("失败");
                location.replace(location.href);
              break;
            }
        }
   });
}

------------------------------------------------------------------------------
我的问题是 调用AJAX 之后直接更换图片不需要在从新刷新一次页面,求大虾帮忙,在线等
------解决方案--------------------
不知道你要做什么?
既然是用了 jquery,那么就该用 jquery 的传统写法
php 部分

<span  class="img"><br /><img  src="/themes/default/images/star02.gif"   style="max-width:90%"starflag'] == 1? '' : 'none' ? alt="AJAX PHP 循环之后点击状态更换图片,该如何解决" >" name="<?php echo $value['name']?>" id="<?php echo $value['id']?>" /> <br /><img  src="/themes/default/images/star01.gif"   style="max-width:90%"starflag'] == 1? 'none' : '' ? alt="AJAX PHP 循环之后点击状态更换图片,该如何解决" >" name="<?php echo $value['name']?>" id="<?php echo $value['id']?>" /> <br /></span><br />
Copy after login


js 部分

$(function() {<br>  $(".img").click(function() {<br>    $(this).children().toggle();<br>    $.post("<?php  echo base_url('test/fangfa'); ?>",<br>      {<br>        n : Math.random(),<br>        fn : escape($(this).attr('id')),<br>        starflag : escape($(this).attr('name'))<br>      },<br>      function(msg){<br>        //你需要的其他处理<br>      });<br>  });<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!