问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

jquery怎么取得form表单的url路径,并提交

发布网友 发布时间:2022-05-15 04:14

我来回答

3个回答

懂视网 时间:2022-05-15 08:36

这次给大家带来jQuery如何转换url地址获取url目录,jQuery转换url地址获取url目录的注意事项有哪些,下面就是实战案例,一起来看一下。

path.makeUrlAbsolute() 把相对URL转化为绝对URL

jQuery.mobile.path.makeUrlAbsolute( relUrl, absUrl )

把相对URL转化为绝对URL的方法。这个函数返回一个字符串,绝对URL。

relUrl:相对网址。类型:字符串。

absUrl:绝对网址。类型:字符串。

<!doctype html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>jQuery.mobile.path.makeUrlAbsolute demo</title>
 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css">
 <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
 <!-- The script below can be omitted -->
 <script src="/resources/turnOffPushState.js"></script>
 <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
 <style>
 #myResult{
 border: 1px solid;
 border-color: #108040;
 padding: 10px;
 }
 </style>
</head>
<body>
 
<p data-role="page">
 
 <p data-role="content">
 <p>The absoulte URL used is http://foo.com/a/b/c/test.html</p>
 <input type="button" value="file.html" id="button1" class="myButton" data-inline="true">
 <input type="button" value="../../foo/file.html" id="button2" class="myButton" data-inline="true">
 <input type="button" value="//foo.com/bar/file.html" id="button3" class="myButton" data-inline="true">
 <input type="button" value="?a=1&b=2" id="button4" class="myButton" data-inline="true">
 <input type="button" value="#bar" id="button5" class="myButton" data-inline="true">
 <p id="myResult">The result will be displayed here</p>
 </p>
</p>
<script>
$(document).ready(function() { 
 $( ".myButton" ).on( "click", function() { 
 var absUrl = $.mobile.path.makeUrlAbsolute( $( this ).attr( "value" ), "http://foo.com/a/b/c/test.html" ); 
 $( "#myResult" ).html( absUrl );
 }) 
});
</script>
 
</body>
</html>

path.get() 确定URL中的目录部分

jQuery.mobile.path.get( url )

url:只有一个参数。类型:字符串。

确定URL中的目录部分的实用方法。如果URL没有斜线,URL的一部分被认为是一个文件。这个函数返回一个给定的URL目录部分。

<!doctype html>
<html lang="en">
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>jQuery.mobile.path.get demo</title>
 <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css">
 <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
 <!-- The script below can be omitted -->
 <script src="/resources/turnOffPushState.js"></script>
 <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
 <style>
 #myResult{
 border: 1px solid;
 border-color: #108040;
 padding: 10px;
 }
 </style>
</head>
<body>
 
<p data-role="page"> 
 <p data-role="content">
 <input type="button" value="http://foo.com/a/file.html" id="button1" class="myButton" data-inline="true" />
 <input type="button" value="http://foo.com/a/" id="button2" class="myButton" data-inline="true" />
 <input type="button" value="http://foo.com/a" id="button3" class="myButton" data-inline="true" />
 <input type="button" value="//foo.com/a/file.html" id="button4" class="myButton" data-inline="true" />
 <input type="button" value="/a/file.html" id="button5" class="myButton" data-inline="true" />
 <input type="button" value="file.html" id="button6" class="myButton" data-inline="true" />
 <input type="button" value="/file.html" id="button7" class="myButton" data-inline="true" />
 <input type="button" value="?a=1&b=2" id="button8" class="myButton" data-inline="true" />
 <input type="button" value="#foo" id="button9" class="myButton" data-inline="true" />
 <p id="myResult">The result will be displayed here</p>
 </p>
</p>
<script>
$(document).ready(function() { 
 $( ".myButton" ).on( "click", function() { 
 var dirName = $.mobile.path.get( $( this ).attr( "value" ) ); 
 $( "#myResult" ).html( String( dirName ) );
 }) 
});
</script>
 
</body>
</html>

相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

推荐阅读:

jquery动态加载Js文件和Css文件步骤详解

jquery解析XML字符串+XML文件步骤详解(附代码)

热心网友 时间:2022-05-15 05:44

获得form的url简单的方法:$('form').attr('action')
表单提交简单方法:$('form').submit();
如果有多个表单,请更换选择器,以便找到你所想控制的表单。
以ajax方式提交可以使用ajaxForm方法。

热心网友 时间:2022-05-15 08:36

<script type="text/javascript">
function uimage() {
monkey.uploadFile("h", {
type: "image"
},function (path){
alert(path);
$("#ren").append("<img src=" + "/Images/Upload/" + path + " id='sctp' style='width:500px;height:500px'/>");
});
}
</script>
</head>
<body>
<input type="file" name="h" id="h" onchange="uimage();"/>
<div id="ren"></div>
</body>
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
米色的双面呢羊毛大衣有哪些时髦又随性的搭配思路值得分享? 双面羊绒大衣搭配什么裤子(短款羊绒大衣搭配什么下装比较好看?) 银杏烤多久熟 银杏果烤着吃是烤干的还是湿的? 签了离婚协议就是离婚了吗 汽车PID检测是什么意思 仪表pid控制什么意思 CAN总线温度传感器 公共管理学说史内容简介 《公共行政学史》读书笔记 如何服务西餐菜肴 夏天如何买到50元以内的好的衣服和裤子? 雅戈尔DP纯棉免烫衬衣怎么样 想选一款男士的t恤,棉的,年龄大楷在40岁左右,价格不要超过300元,嘿嘿,物美价廉更好! 这件衬衣大概50元左右,一点也不贵。修改病句? 什么牌子的男装衬衫穿了不易皱?100元到150元之间的. 豆芽和粉条怎么做好吃 芸豆炖粉条的做法,芸豆炖粉条怎么做好吃,芸豆 豆腐乳和土豆可以一起吃吗 青方腐乳配什么好吃? 线豆炖粉条怎么做好吃 豆腐与豆腐乳同时吃吗 吃豆腐乳时能同时吃韭菜吗 白菜豆粉条怎样炖好吃 豆腐乳和鸡蛋可以同时吃吗 豆腐乳和香菇莲米芡实可以一起吃吗? 腐乳怎么搭配好吃 豆腐乳配什么吃最好吃? 钻石莫桑钻和锆石的识别,这区别方法,真的长见识了! 油炸花生米,怎么样做香脆? 我买的手机优盘里面装着大白菜软件怎么给电脑装系统啊? 数量单位 英文字符 计量单位“台”“个”用英语怎么表示? 北京丰台区政府附近买房环镜怎样? 二氧化碳的作用? 中国移动怎么发短信更改套餐流量 jquery 如何获取iframe跳转 后的url 如何让员工主动的加班? 怎么才能让现在的年轻人愿意加班? 如何让员工心甘情愿地加班? 如何才能让员工加班?并且做起事情很有干劲?? 怎样让员工加班 怎么让员工晚上加班 公司如何让员工主动加班? 公司怎么才能强迫员工加班? 如何让下属加班 李泽尧:如何让员工愿意加班 公司该如何合法安排员工加班 公司想让员工周末加班,请问加班通知要怎么写? 如何让员工心甘情愿为老板加班? 如何跟员工说加班