在这种情况下,如何在jquery中的函数内部连接值? [英] How can I concatenate a value inside function in jquery in this situation?

查看:107
本文介绍了在这种情况下,如何在jquery中的函数内部连接值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在jquery中的函数内部连接一个值.请参阅下面的代码.我想将值数据1放入函数中.你有什么办法实现我想要的吗?感激.

I want to concatenate a value inside function in jquery. See code below. I want to put value data 1 into a function. Do you have any way to achieve what I want? Appreciate.

     var data='1';
	var user='<?php echo bp_core_get_user_domain('+ data +');?>';
				
         $("#find_members").html(user);

推荐答案

制作一个空的php页面.

Make an empty php page.

file.php

在其中放入要与JS值交互的PHP.

Inside put the PHP you want to interact with the JS value.

<?php 
function bp_core_get_user_domain($something) {
     //do Stuff here
      return $something;
}
echo bp_core_get_user_domain($_POST['data_var']);
?>

然后在您的页面上对此脚本发出ajax请求,数据将返回...

Then on your page make an ajax request to this script and the data will come back...

var data='1';
$.post( "file.php", { data_var: data})
  .done(function( data ) {
    $("#find_members").html(data);
  });

这是一个粗略的版本(未经测试),为此有很多示例.

This is a rough version (untested), there are MANY examples out there for this.

这篇关于在这种情况下,如何在jquery中的函数内部连接值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆