【发布时间】:2018-05-07 19:06:34
【问题描述】:
如何使用 console.log 的值来更改图像而不在我的 css 中动态重新加载页面图像?
function reply_click(clicked_id){
$(function() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
console.log('attached');
$('#openButton').on('click', function(data) {
console.log('clicked');
$.ajax({
type: "POST",
url: "/MYUrl",
data: { _token: $('meta[name="csrf-token"]').attr('content') }
})
.done(function(data){
console.log(data);
})
.fail(function(data){
console.log('Error:', data);
});
});
});
}
我把我要更新的图片 来自我的blade.php
<div class="inputbutton">
<span class="text">TEXT</span>
<input type="submit" class="btTxt submit" value="" id="TEXT" onclick="reply_click(this.id)">
</div>
我的css文件
div.inputbutton input {
background: url('/img/myimg.png') no-repeat;
cursor: pointer;
width: 100px;
height: 130px;
border: none;
background-size: 100%;
}
【问题讨论】:
-
你可以试试
$('#imageid.or.class').attr('src',data);。 -
没用!!!
-
console.log(data) 给你什么?您需要了解您的内容才能正确使用它