×

thinkphpjquery

关于thinkphpjquery的信息

admin admin 发表于2023-04-05 10:25:14 浏览69 评论0

抢沙发发表评论

本文目录一览:

thinkphp jquery的$post然后跳转怎么实现?

function willCate(){

$.post("{:U('Home/SellSth/willcate')}", { "id":"你的商品id" },

   function(data){

window.location.href="你要跳转的地址";

   }, "text");

   }

post后有一个请求成功的函数 在那个函数里加跳转代码就可以了

thinkphp 下使用jQuery.ajax路径url怎么写

jQuery.ajax路径url写法如下:

jQuery 代码写法:

$(document).ready(function(){

$("#b01").click(function(){

htmlobj=$.ajax(

{

url:"/jquery/test1.txt",

async:false});

$("#myDiv").html(htmlobj.responseText);

});

});

thinkPHP怎么导入jq

首先将jq库文件放入项目文件下,然后以相对路径加载jq库文件,比如:

script type="text/javascript" src="/jq/jquery.min.js"/script

具体路径要看库文件放的位置,调整一下就可以了。

thinkphp+jquery ajax分页问题,求助

public function articleList($p = null)

{

    $db = M('article');

    $p = intval($p) ? intval($p) : 1;

    $pageSize = 30;

    $offset = ($p - 1) * $pageSize;

    $articleList = $db-where(array('category' = '1'))-order('time')-limit($offset,$pageSize)-select();-thinkphpjquery

    $count = $db-where(array('category' = '1'))-select();

    $page = new \Think\Page($count,$pageSize);

    $page = $page-show();

    $this-assign('page',$page);

    $this-assign('articleList',$articleList);

    $this-display();

}

你应该看得懂

怎么用Thinkphp+jquery实现ajax的提交,接收处理和返回

$.post(url,{a:1,b:2},function(ret){

接收返回值

})

TP:

$a = I('post.a');

$b = I('post.b');

$this-success("OK");

TP会自动判断是否是ajax提交的,在success输出时如果是ajax那么就是json对象,否则则是调用模板的

用ThinkPHP+JQuery实现无刷新点赞、踩、收藏功能

//点赞

$(".log_digg").on('click', function () {

var post_id = $(this).parent().parent().find(".post_id").val();

var log_digg_num =$(this).find(".log_digg_num_"+post_id).html();

log_digg_num=parseInt(log_digg_num);

var text = $(this).find(".digg_text_"+post_id).text();

if(text=="点赞"){

$.post(URL_PATH+"/index/Index/digg_log",{'post_id':post_id},function(data){

var data=JSON.parse(data);//接收解码的数据

if(data.code=="200"){

alert(data.msg);

log_digg_num = log_digg_num+1;

$(".log_digg_num_"+post_id).html(log_digg_num);

$(".digg_text_"+post_id).text('取消点赞');

}

else

{

alert('点赞失败');

}

});

}

else{

$.post(URL_PATH+"/index/Index/cancel_digg_log",{'post_id':post_id},function(data){

var data=JSON.parse(data);//接收解码的数据

if(data.code=="200"){

alert(data.msg);

log_digg_num = log_digg_num-1;

$(".log_digg_num_"+post_id).html(log_digg_num);

$(".digg_text_"+post_id).text('点赞');

}

else

{

alert('取消点赞失败');

}

});

}

})

如果需要后台传输就用ajax的给你个例子:

$.ajax({ url: "test.html", context: document.body}).done(function() { $(this).addClass("done");});-thinkphpjquery