我已经花了10多个小时来解决这个问题,并且基本上在整个互联网上寻找解决方案.这是一个简单的jQuery ajax POST方法,我在成功之前已经使用了几次.在过去我也有这个问题,但不知何故解决了它.我传递的数据似乎没问题,在chrome的网络控制台中它甚至显示了一个包含所谓数据的成功帖子.但是,使用.load来获取该数据始终返回null.在下面的代码中,我使用了一个表单,我阻止了默认提交以防止刷新.一个按钮触发sellBook(),它会提示一个表单,然后提交触发post().
JS
function sellBook(i) {
$('#results').html('');
title = books[i].title;
author = books[i].author;
ISBN = books[i].ISBN;
publisher = books[i].publisher;
image = books[i].image;
year = books[i].year;
$('#results').html('Listing for ' + books[i].title + ' by ' + books[i].author + '<br><br><form method="post" action="https://localhost/textbookexchange/db2.php" id="sellIt">Edition #: <input type="text" id="edition" name="edition"/><br><br>Price: $<input type="text" id="price" name="price"><br><br>Condition: <input type="text" id="condition" name="condition"><br><br><input type="submit" value="Submit"><br><br></form>');
getInfo();
$('#sellIt').submit(function () {
post();
return false;
});
}
function post() {
price = document.getElementsByName('price')[0].value;
edition = document.getElementsByName('edition')[0].value;
condition = document.getElementsByName('condition')[0].value;
var formData …Run Code Online (Sandbox Code Playgroud) 我有一个可以切换 div 的工作脚本,它运行良好,但我不知道如何在单击时更改按钮文本。当显示价差 div 时,我需要按钮文本为“隐藏价差”,当未显示价差 div 时,我需要“显示价差”。
脚本:
$(document).ready(function(){
$(".spread").show();
$(".show_hide").show();
$('.show_hide').click(function(){
$(".spread").toggle();
});
});
Run Code Online (Sandbox Code Playgroud)
按钮:
<input type="button" class="show_hide" value="Hide Spreads" />
Run Code Online (Sandbox Code Playgroud) 这可能是一个简单的解决方案的问题,但我现在已经坚持了一段时间.我有一个按钮,一旦文本框被填充,将使用Jquery加载pdf.但是,在我的测试中,只要单击按钮,模态就会出现并消失.我已经把它剃掉了以使div首先出现并且同样的事情发生了.它可能是我的代码的东西,或者它是多少脚本被调用?
HTML
<form>
<p>Key number : <input type="text" name="keynumber" /></p>
<p><button id="submit" class="retrievedoc" type="submit" >Submit</button></p>
</form>
<div id="pdf-dialog">
<p>TEST</p>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.pdf-dialog{display:none;}
Run Code Online (Sandbox Code Playgroud)
JQuery的
$('.retrievedoc').on('click', function() {
$("#pdf-dialog").show();
/**$(".pdf-dialog").dialog({
title: 'Document',
width: 500,
height: 800,
draggable: false,
modal: true,
dialogClass: "readpdf-dialog",
buttons: [{
text: 'Close',
click: function() {
$(this).dialog('close');
}
}]
});
**/
});
Run Code Online (Sandbox Code Playgroud)
这就是我在页面底部安排脚本的方法
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!-- Include all compiled plugins (below), or include individual …Run Code Online (Sandbox Code Playgroud) 在ColdFusion中,我可以执行此操作
<cfscript>
favorites = [{"broker_label":"spectra"}];
for (afav in favorites) {
writedump(afav);
}
</cfscript>
Run Code Online (Sandbox Code Playgroud)
我得到数组中的每一行。
如果我在Javascript中尝试
favorites = [{"broker_label":"spectra"}];
for (var afav in favorites) {
console.log(JSON.stringify(afav));
}
Run Code Online (Sandbox Code Playgroud)
我得到的只是0,或者确切地说是0。 "\"0\""
到底是怎么回事?
我对jquery相当新,并且仍然在寻找我的方式.一旦图像加载到特定的div中,我正在尝试执行一个函数.
这是我的代码.
$('#advanced-slideshow img').load(function() {
var idx = $('#mycarousel li a.activeSlide').data('index') - 2;
carousel.scroll(idx);
return false;
});
Run Code Online (Sandbox Code Playgroud)
我想要的是每次将图像加载到div中,#advanced-slideshow我希望我的函数能够执行.
任何有关这方面的帮助都会很棒!
我想只删除已检查的div元素.我的脚本删除所有动态创建的div元素.我做错了什么?
HTML:
<div class="container">
<form>
<p>Title:</p>
<input type="text" id="title" />
<p>Link:</p>
<input type="text" id="link" />
</form>
<br>
<button class="btn btn-success">Add</button>
<button class="btn btn-danger">Delete</button>
</div>
<div class="content" style="margin-top:50px">
<div class="content_wrapper"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$(function () {
$(".btn-success").click(function () {
var title_val = $("#title").val();
var link_val = $("#link").val();
$(".content").append('<div class="content_wrapper"><div class="col-xs-6 col-md-4"><ol class="breadcrumb"><h4>' + title_val + '</h4><input type="checkbox" class="checkbox"></ol><a href="http://' + link_val + '" class="thumbnail"></a></div></div>');
});
$(document).on("click", ".btn-danger", function () {
if ($(".checkbox").is(":checked")) {
$(".content_wrapper").remove();
}
});
});
Run Code Online (Sandbox Code Playgroud)
我在下面的插入符号类中有此html代码fa fa-caret-down。现在,我希望如果用户单击插入符,则删除插入符的类将被替换为fa fa-caret-up该类。同样,如果他踢了插入式上课,它将回到插入式上课。
(任何其他方式也可以)。我已经试过了:
$(document).ready(function() {
$('.fa-caret-down').on('click', function () {
$(this).removeClass('fa-caret-down').addClass('fa-caret-up');
});
$(this).removeClass('fa-caret-up').addClass('fa-caret-down');
});
Run Code Online (Sandbox Code Playgroud)
[此代码在此代码中也运行得非常糟糕]
但这仅适用于第一部分。如果我想回到插入符号,则什么也没发生。
那就是我的HTML:
<div id="acc-construct" class="hidden">
<div class="acc-group">
<div class="acc-head">
<a class="acc-toggle collapsed acc-default" data-toggle="collapse"
data-parent="#acc" href="#collapse-divsInContainer">
<i data-arrow="" class="pull-right fa fa-caret-down"></i>
</a>
</div>
<div id="collapse-divInContainer" class="acc-body collapse">
<div class="acc-inner">
<dl class="dl-horizontal"></dl>
<div class="separator"></div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我在jquery / Js中仍然是新手,对不起我的英语不好。
谢谢你的帮助 !
我正在使用自定义标签,但收到以下内容的无效 CFML 构造错误:
第 27 行第 10 列发现无效的 CFML 构造。
26 : <cfscript>
27 : cfparam( 'attributes.action', 'new' );
28 : cfparam( 'attributes.fieldList', '' );
29 : cfparam( 'attributes.return', 'variables' );
Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的CFML代码转换为CFScript,但我收到了CFHtmlToPdf的错误.
CFML:
<cfoutput>
<cfhtmltopdf orientation="portrait" pagetype="A4" margintop="1" marginbottom="1" name=pdfFile>
#arguments.data.HTMLData#
</cfhtmltopdf>
<cfmail type=HTML to="#arguments.data.Email#" from="support@mydomain.com" subject="Form Test" server="localhost">
TEST
<cfmailparam file="#arguments.data.ReportName#.pdf" type="application/pdf" content="#pdfFile#"/>
</cfmail>
</cfoutput>
Run Code Online (Sandbox Code Playgroud)
我的cfscript代码:
cfhtmltopdf(source=arguments.data.HTMLData, destination=pdfPath);
mailerService = new mail();
mailerService.setTo("arguments.data.Email");
mailerService.setFrom("support@mydomain.com");
mailerService.setSubject("Form Test");
mailerService.setType("html");
mailerService.addParam(file="Test.pdf",type="application/pdf",content=pdfPath);
mailerService.send(body="Test");
Run Code Online (Sandbox Code Playgroud)
我收到错误:
src不是正确的URL,或者绝对路径指定的文件不存在.
行中出现错误:
cfhtmltopdf(source=arguments.data.HTMLData, destination=pdfPath);
Run Code Online (Sandbox Code Playgroud)
我在cfscript中错误地使用CFHtmlToPdf吗?
使用 react-dropzone 上传文件,我想以文件传输或 mbs 数据传输的百分比来实现文件进度。
这是链接:https : //react-dropzone.netlify.com/
onDrop(acceptedFiles, uploadApi) {
const filesToBeSent = this.state.filesToBeSent;
if (acceptedFiles.length) {
if (acceptedFiles[0].type === FileTypeList.TYPE) {
filesToBeSent.push(acceptedFiles);
const formData = new FormData();
formData.append("file", acceptedFiles[0]);
uploadApi(formData).then((response) => {
this.setState({
filesPreview: [],
filesToBeSent: [{}],
showNotification: true,
uploadResponse: response,
});
this.props.fetchHistory();
});
} else {
this.setState({
fileType: true,
});
}
} else {
this.setState({
fileSize: true,
});
}
}
Run Code Online (Sandbox Code Playgroud)
<Dropzone maxSize={this.props.maxSize} onDrop={(files) => this.onDrop(files, this.props.uploadApi)}>
{({ getRootProps, getInputProps }) => {
return (
<div {...getRootProps()} …Run Code Online (Sandbox Code Playgroud)