SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Philippines
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery classic ASP question

    What is wrong with the jquery URL: link??

    Code:
    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).

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    689
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you may want to move this to the jquery forum - not really an ASP issue.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,140
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    - Moved -

    I'm wondering why you're mixing jquery selector syntax with getElementBy syntax. Wouldn't it be best to be consistent?

  4. #4
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Philippines
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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;

    Code:
    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;

    Code:
    function loadingAjax(div_id) {
    	$("#"+div_id).html('<img src="images/wait.gif">');
    	$.ajax({
    		type: "POST",
    		url: myLink,
    		success: function(msg){
    			$("#"+div_id).html(msg);}
      	});
      }

  5. #5
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Philippines
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to make it clear, I will include these classic ASP files.

    main file; Loader.asp
    Code:
    <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
    Code:
    <%@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.

  6. #6
    SitePoint Member
    Join Date
    Jan 2012
    Location
    Philippines
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I think I got it... though it is not a single jquery command. The code is follows;

    Code:
    <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?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •