thinkphp3.2.3+jquery的问题

juqery ajax通过get传递参数怎么给页面带上

比如
$(document).ready(function(){

 $.ajax({
    url:'<?php echo U('Index/index');?>',
    data:"name="+$("#name").val(),
    success:function(){
    
    }
 });

})

clipboard.png

阅读 2.4k
2 个回答

写在success里
history.pushState(null, null, location.pathname + '?name=android')

js代码如下:
$.ajax({
                      type: 'GET',
                      url: "{:U('Code/save_code')}",
                      data: data.field,
                      dataType: 'json',
                      async: false,
                      success: function(result) {
                            if (result.code=='0') {
                                  alert(result.msg);
                            }else{
                                 alert(result.msg);
                                

                            }
                      },
                      error: function() {
                              
                      }
                      
            
                       
                    });
                      

                    
                });
                
                
//php代码
<?php
    $name =$_GET['name'];
    $r['code'] ='0';         
    $r['msg'] = $name;
    exit(json_encode($r));
?>                
                
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进