我在移动应用程序中,我使用输入字段,以便用户提交一个号码.
当我返回并返回到输入字段的页面时,显示输入字段中显示的最新数字输入.
有没有办法在每次页面加载时清除该字段?
$('#shares').keyup(function(){
payment = 0;
calcTotal();
gtotal = ($('#shares').val() * 1) + payment;
gtotal = gtotal.toFixed(2);
$("p.total").html("Total Payment: <strong>" + gtotal + "</strong>");
});
Run Code Online (Sandbox Code Playgroud) 我在移动应用程序中,我使用多个Ajax调用从Web服务器接收数据,如下所示
function get_json() {
$(document).ready(function() {
$.ajax({
url: 'http://www.xxxxxxxxxxxxx',
data: {
name: 'xxxxxx'
},
dataType: 'jsonp',
//jsonp: 'callback',
//jsonpCallback: 'jsonpCallback',
success: function(data) {
$.each(data.posts, function(i, post) {
$.mobile.notesdb.transaction(function(t) {
t.executeSql('INSERT into bill (barcode, buildingcode, buildingaddress, flatname, flatdescription, entryseason, period, amount, pastpayments, todaypayments, paydate, receiptno) VALUES (?,?,?,?,?,?,?,?,?,?,?,?);', [post.Id, post.Code, post.Address, post.Name, post.Description, post.EntrySeason, post.Period, post.Revenue, post.PastPayments, post.todaypayments, post.paydate, post.receiptno],
//$.mobile.changePage('#page3', 'slide', false, true),
null);
});
$('#mycontent').append(post.Name);
});
}
});
$.ajax({
xxxx
});
$.ajax({
xxxx
});
});
}
Run Code Online (Sandbox Code Playgroud)
如何强制第二次ajax呼叫在第一次结束后开始...第二次结束后第三次继续?
我想检查我的android设备中的目录中是否有某个文件.
我在windows批处理中使用以下行
adb shell find /mnt/sdcard/koinoxrista -name Bill.txt
Run Code Online (Sandbox Code Playgroud)
如果文件存在,我想做一些事情,如果文件不存在,我想做其他事情.
我怎样才能做到这一点?
我正在使用以下代码来查找图像的垫轮廓.我发现轮廓正确.但是当我尝试在轮廓处裁剪图像时,应用程序崩溃了.我哪里错了?
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Imgproc.findContours(imageA, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
for(int i=0; i< contours.size();i++){
if (Imgproc.contourArea(contours.get(i)) > 50 ){
Rect rect = Imgproc.boundingRect(contours.get(i));
if (rect.height > 28){
Core.rectangle(image, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height),new Scalar(0,0,255));
Mat ROI = image.submat(rect.x, rect.x + rect.heigth, rect.x, rect.x + rect.width);
Highgui.imwrite("/mnt/sdcard/images/test4.png",ROI);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我使用下面的代码,以便从收集器文本文件的前4个字符的值创建一个目录
@echo off & setlocal enabledelayedexpansion
:loop
set /P txt_file=<Collector.txt
Set collector_id=!txt_file:~0,4!
:: check for existence of [OutputFolder]
:: if [OutputFolder] doesn't exist, create it
if not exist %collector_id% (
echo folder %collector_id% not found
echo creating folder %collector_id%
md %collector_id%
)
xcopy *.txt %collector_id% /v
Del *.txt
goto loop
Run Code Online (Sandbox Code Playgroud)
我想连续执行上面的循环,以检查当前目录是否为空.如果不是我想制作一个目录,如果不存在,名称为collector.txt的前4个字符.
如果目录不为空,一切正常.当上面循环并且我将collector.txt添加到当前目录时,collector_id不会改变.
我哪里错了?
有没有其他方式,期望无限循环来做到这一点?
我有以下JSON字符串:
var billjson = "({'posts' : [{'Id' :' 7553','Code' :'1186 ','Address' :' GGGG 39? ','Name' : ' GGGG NAME 3 ','Description' : ' G 3 ','EntrySeason' : ' GGGGG 08-09 ','Period' : ' 10/2009 ','Revenue' : ' 4.10'},{'Id' :' 7553','Code' :'1186 ','Address' :' GGGG 39? ','Name' : ' FFFF NAME 3 ','Description' : ' F 3 ','EntrySeason' : ' FFFF 08-09 ','Period' : ' 10/2009 ','Revenue' : ' 4.10'}]})"
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用代码创建一个JSON对象:
var mybilljson = jQuery.parseJSON( billjson );
Run Code Online (Sandbox Code Playgroud)
但控制台的结果是:
未捕获的无效JSON:
为什么?