[英]how to pass parameter to URL in javascript?
我需要將參數傳遞給URL。我已經擺好了代碼。
如何將在文本框中輸入的username
和password
傳遞給代碼中的網址。感謝您的幫助。
您不應在URL中發送password
。
如果要傳遞其他一些詳細信息:如下更新這兩行:
data: {data1:$("input#data1").val(),data2:$("input#data2").val()},
url: "http://localhost:53179/hdfcmobile/hdfc.ashx",
如果要傳遞url參數,則要使用:
type: 'GET'
並且:
url: 'http://localhost:53179/hdfcmobile/hdfc.ashx
到.ajax配置中,使用類型:“ POST”會將字段發布到標頭(而不是url)中。
試試下面的代碼:
您可以按這種模式嘗試代碼...
var sdate = $('#banners_startdate').val();
var edate = $('#banners_enddate').val();
if(sdate != '' && edate != ''){
$.ajax({
url: 'your url',
data: 'apiname=get_banner_stat_platform_sharing&var=bannerstats&sdate=' + sdate + '&edate=' + edate,
dataType: 'html',
success: function(data){
$('#bannerstats').html(data);
return false;
}
});
}
可以通過id獲取用戶名和密碼的位置:
function ajaxcall(username,password)
{
jQuery.ajax({
type: "POST",
url: "Enter Url to pass",
data: {user: username, pass: password},
dataType: "html",
success: function(data) {
//write code what you want to do here
}
});
}
您可以通過$_POST['user']
和$_POST['pass']
來獲取頁面上的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.