我在我的wp主题中设置了基本的wordpress ajax示例.触发器由modernizr.js检查页面上的媒体查询.
jQuery(document).ready(function($) {
if(Modernizr.mq('only all and (max-width:6300px)')) {
var data = {
action: 'my_action',
whatever: ajax_object.we_value // We pass php values differently!
};
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
jQuery.post(ajax_object.ajax_url, data, function(data) {
$("#trending-Container").html(data).fadeIn(1000);
});
}
});//end function
Run Code Online (Sandbox Code Playgroud)
我已经对我的脚本进行了本地化和排队.
wp_enqueue_script('mainJS', get_template_directory_uri() . '/js/mainJS.js', array("jquery") );
wp_localize_script( 'mainJS', 'ajax_object',
array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'we_value' => 1234 ) );
Run Code Online (Sandbox Code Playgroud)
最后处理请求的函数是:
add_action('wp_ajax_my_action', 'my_action_callback');
add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
function my_action_callback() {
global $wpdb; …Run Code Online (Sandbox Code Playgroud) 这可能是一个非常简单的问题,但请原谅我,因为我是新人.这是我的代码:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main ()
{
string name;
int i;
string mystr;
float price = 0;
cout << "Hello World!" << endl;
cout << "What is your name? ";
cin >> name;
cout << "Hello " << name << endl;
cout << "How old are you? ";
cin >> i;
cout << "Wow " << i << endl;
cout << "How much is that jacket? ";
getline (cin,mystr);
stringstream(mystr) >> price;
cout …Run Code Online (Sandbox Code Playgroud) 这种嵌套div在FireFox和Chrome中的呈现方式不同.Chrome,结果我正在寻找.一个div可以与内容增长的另一个里面div有一个填充20px.
效果应该看起来像20px嵌套的上方和下方div一样(在Chrome中).
http://jsfiddle.net/SEOplay/58xRJ/2/embedded/result/
我正在使用的代码:
HTML
<section>
<div class="dualContainer">
<div class="dualBgBlock"></div>
<div class="dualMiddle">
<div class="dualContent"></div>
</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
CSS
div.dualContainer {
margin-top:50px;
margin-bottom:20px;
position:relative;
z-index:0;
width:100%;
}
div.dualBgBlock {
position:absolute;
top:0;
bottom:0;
right:0;
left:0;
margin:auto;
background-color:#ccc;
width:60%;
height:100%;
padding:20px;
}
div.dualMiddle {
width:80%;
margin:0 auto;
}
div.dualContent {
background-color:#333;
overflow:hidden;
position:relative;
height:200px;
}
Run Code Online (Sandbox Code Playgroud)
链接到小提琴:http: //jsfiddle.net/SEOplay/58xRJ/2/
那么我怎样才能让FireFox以Chrome的方式呈现我的代码呢?
我正在做一些重构,并尝试使用更高级别的组件连接到redux,connect()但我正在连接的组件不断给我空道具.
我已经包含了相关的代码,我将我的redux reducer结构化为ducks格式,因此actions/creators和reducers在一个模块文件中.
这些文件是containers/login.js,presentation/login.js,presentation/logins.js,app.js和根index.js.
当我决定重命名某些操作,文件和缩减器时,将连接移动到更高的组件,连接停止工作,现在我有空道具.
非常感谢.
// containers/login.js
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom'
import { fetchPage } from '../redux/modules/Login';
import Login from '../presentation/Login';
const mapStateToProps = (state) => {
return {
page: state.page,
forms: state.forms
}
}
const mapDispatchToProps = (dispatch) => {
return {
fetchPage: () => dispatch(fetchPage())
} // here we're mapping actions to props
}
export …Run Code Online (Sandbox Code Playgroud) 我无法将定义长度的char序列数组存储到struct的对象中.我可以在没有定义字符长度或只使用字符串的情况下使其工作,但它只是困扰我为什么会发生这种情况.
代码:
#include <iostream>
#include <string>
using namespace std;
struct highscore {
char name[50];
int score;
char date[10];
} hstable[9];
void printtable (highscore show_tab) {
cout << show_tab.name << show_tab.score << show_tab.date;
};
void main() {
hstable[0].name = "Kyle ";
hstable[0].score = 100;
hstable[0].date = " 01/03/88 \n";
printtable (hstable[0]);
system("pause");
return;
};
Run Code Online (Sandbox Code Playgroud)
错误:
错误C2440:'=':无法从'const char [6]'转换为'char [50]'1>没有可以进行此转换的上下文
错误C2440:'=':无法从'const char [12]'转换为'char [10]'
我不知道为什么我得到错误C2143:语法错误:缺少';' 在'==之前如果有人会解释我的错误,我将不胜感激.
#include <iostream>
#include <string>
#include <cstdlib>
int main() {
std::cout << "What is your name? ";
std::string name;
std::cin >> name;
const std::string greeting = "Hello " + name + " !";
//
const int pad = 1;
const int rows = pad * 2 + 3;
std::cout << std::endl;
//
int r = 0;
while (r != rows) {
std::cout << std::endl;
++r;
}
//
std::string::size_type cols = greeting.size() + pad * 2 + 2;
std::string::size_type c …Run Code Online (Sandbox Code Playgroud) 我试图将一个导航元素提升到一个级别,所以我最终会得到类似的东西:
<div>
<nav>
<a href='#'>hello</a>
<a href='#'>hello</a>
</nav>
</div>
Run Code Online (Sandbox Code Playgroud)
至
<nav>
<a href='#'>hello</a>
<a href='#'>hello</a>
</nav>
<div>
</div>
Run Code Online (Sandbox Code Playgroud)
我一直在尝试使用unwrap(); 没有成功.
$('div > nav').unwrap();
Run Code Online (Sandbox Code Playgroud)
不完全确定原因.
在Android 4.0.4,股票浏览器上,我无法设置图像的最大高度.目前它在容器外面呈现.
HTML
<div class="dualBlock">
<div class="dualImage col-postImage">
<img src="http://placekitten.com/300/600" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.dualBlock {
width:80%;
margin:50px auto;
}
div.dualImage {
max-height:300px;
width:100%;
position:relative;
text-align:center;
background-color:red;
}
div.dualImage img {
max-width:100%;
max-height:100%;
}
Run Code Online (Sandbox Code Playgroud)
小提琴 http://jsfiddle.net/SEOplay/QkEtq/1/
这在chrome中正常工作并按预期呈现,问题仅发生在Android股票浏览器上.
如果我定义一个高度.dualImage,比如说300px就可以了.为什么Android只接受定义的高度,如何在其库存浏览器上使用它?
我有一个PHP变量,我试图传递给一个javascript函数.使用纯PHP我将回显所需的字符串输出,但当我把它推入变量并在javascript中输出它不起作用.
似乎javascript似乎没有看到任何东西.
这是代码:
<?php $a = get_post_thumbnail_id( $post -> ID ); ?>
<?php $img = wp_get_attachment_image_src( $a ); ?>
<?php $b = $img[0]; ?>
<script type="text/javascript">
var myVar = <?php echo $b; ?>;
alert(myVar);
</script>
Run Code Online (Sandbox Code Playgroud)
虽然这只是我正在努力工作的一段测试代码,但我试图使用这样的结果:
<?php $a = get_post_thumbnail_id( $post -> ID ); ?>
<?php $img = wp_get_attachment_image_src( $a ); ?>
<?php $b = $img[0]; ?>
<script type="text/javascript">
$(".imgWindow").backstretch("<?php echo $b; ?>");
</script>
Run Code Online (Sandbox Code Playgroud)
显然有一些强调PHP和Javascript的主要内容我必须要丢失.
请赐教.帮助赞赏.