What is wrong with the jquery URL: link??
function loadingAjax(div_id) {
$("#"+div_id).html('<img src="images/wait.gif">');
$.ajax({
type: "POST",
url: "Page1_sub.asp?qFunc=89&qMonth=" + document.getElementById("qTheMonth").value + "&qYear=" + document.getElementById("qTheYear").value,
success: function(msg){
$("#"+div_id).html(msg);}
});
}
The Page1_sub.asp page is executed BUT carrying only the ‘document.getElementById(“qTheMonth”).value’ and the second ‘document.getElementById(“qTheYear”).value’ is not passed. Is there any good way of concatenating a URL link in jquery using the getElementByID in the DOM?? I cant seem to figure JQuery out yet (beginner).
you may want to move this to the jquery forum - not really an ASP issue.
I’m wondering why you’re mixing jquery selector syntax with getElementBy syntax. Wouldn’t it be best to be consistent?
Im a jQuery beginner and got the code from googling… it is working if I am passing a single getElementById… but if I will pass two or more, it wont work. I didn’t know as well that I went out of the boundary of jQuery by using “getElementById” syntax. As with the code below, how can I get the URL to be as say;
var myLink = "Page1_sub.asp?qFunc=89&qMonth=" + document.getElementById("qTheMonth").value + "&qYear=" + document.getElementById("qTheYear").value
and use it “within” same jQUERY code as;
function loadingAjax(div_id) {
$("#"+div_id).html('<img src="images/wait.gif">');
$.ajax({
type: "POST",
url: myLink,
success: function(msg){
$("#"+div_id).html(msg);}
});
}
Just to make it clear, I will include these classic ASP files.
main file; Loader.asp
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>Ajax Page Loader</title>
<meta http-equiv="content-type" content="text/html; charset=us-ascii" />
<script type="text/javascript" src="scripts/jquery142_min.js"></script>
<script type="text/javascript">
function loadingAjax(div_id) {
$("#"+div_id).html('<img src="images/wait.gif">');
$.ajax({
type: "POST",
url: "Loader_sub.asp?qFunc=event&qTrnMonth=" + document.getElementById("qMonth").value + "&qTrnYear=" + document.getElementById("qYear").value,
data: "qCompany=myCompany",
success: function(msg){
$("#"+div_id).html(msg);}
});
}
</script>
</head>
<body>
<div id="mainbox">
<h4>AJAX PAGE LOADER</h4><hr />
<input type="text" name="qMonth" id="qMonth" />
<input type="text" name="qYear" id="qYear" />
<br /><br />
<input type="button" class="btn" name="btnSubmit" id="btnSubmit" value="View Now" onclick="loadingAjax('ajaxDiv');" />
<div id="ajaxDiv"></div>
</div>
</body>
</html>
The second file; Loader_sub.asp
<%@language="vbscript" codepage="1252"%>
<%
'start with the routine
Dim qry, trnMonth, trnYear
qry = trim(request.Querystring("qFunc"))
if qry = "event" then
trnMonth = trim(request.Querystring("qTrnMonth"))
trnYear = trim(request.Querystring("qTrnYear"))
response.Write("Month is; " & trnMonth)
response.Write("Year is; " & trnYear)
end if
%>
What I wanted is to load the second page into the <div id=“ajaxDiv”></div>. Because, eventually I am going to change the second page to load large data which will make the page loading slow. Is there anyone her who could help me? Thanks.
Okay, I think I got it… though it is not a single jquery command. The code is follows;
<script type="text/javascript">
function loadingAjax(div_id) {
var theDiv = div_id;
var theLink = "testLoader_sub.asp?qFunc=event&qTrnMonth=" + document.getElementById("qTransmonth").value + "&qTrnYear=" + document.getElementById("qTransyear").value;
loadNow(theDiv, theLink);
}
function loadNow(myDiv, myLink) {
$("#"+myDiv).html('<img src="images/wait.gif">');
$.ajax({
type: "POST",
url: myLink,
data: "qCompany=iNFODynamics",
success: function(msg){
$("#"+myDiv).html(msg);}
});
}
</script>
Instead I ended up using javascript prior using the Jquery command by passing the concatenated link (myLink) and DIV id. I just wanted to use pure JQuery but I need to study more I guess. Is there any good advices out there?