Reputation: 85
I need to pass the parameters to URL.I have posed the code.
How can I pass the username
and password
entered in the textbox to URL in my code.thanks for any help..
Upvotes: 1
Views: 2646
Reputation: 382
Where username and password can be fetch by 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
}
});
}
You can fetch the value on page by just $_POST['user']
and $_POST['pass']
.
Upvotes: 0
Reputation: 34367
You should not send password
in the URL.
If you want to pass some other details: Update these two lines as below:
data: {data1:$("input#data1").val(),data2:$("input#data2").val()},
url: "http://localhost:53179/hdfcmobile/hdfc.ashx",
Upvotes: 1
Reputation: 2600
Try below code:
You can try your code in this pattern...
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;
}
});
}
Upvotes: 0
Reputation: 1725
if you want to pass a url parameter, the you want to use:
type: 'GET'
and also:
url: 'http://localhost:53179/hdfcmobile/hdfc.ashx
into the .ajax configs, using type:'POST' will post the fields into the headers instead of the url.
Upvotes: 0