Results 1 to 3 of 3

Thread: can ASP be used inside jQuery?

  1. #1
    Join Date
    Feb 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default can ASP be used inside jQuery?

    Hi all

    I was trying to add a simple link to some products on my site, the link was going to the products main page.

    the link uses the .asp code
    Code:
    <%=rs("pID")%>
    to go to the product page...

    below is the jquery i tried to use:

    Code:
    ;$(function(){
    $('div.prodprice').after('<p class="no_space" align="center">
    <a class="ectlink" href="../proddetail.asp?prod=<%=rs("pID")%>">
    <img src="../images/imgconfopts.gif" alt="View Details" width="115px" border="0" />
    </a></p>')
    });
    it doesnt work, the link seems to break at the first " inside
    Code:
    <%=rs("pID")%>
    does anyone know a way around this?

    thanks
    James

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    ASP processes and generates the page, then sends this to the browser. After that, Javascript runs in the browser.
    The two cannot function at the same time.

    Are you trying to set an initial value in ASP for the JS? This is possible. If this is not working, there must be an error in your ASP-- you might want to post in the ASP forum about that.

    But if you are trying to continuously use ASP through the JS, that will never work like that because of the way that ASP is processed first, then JS.
    In order to do that, you will need to use "Ajax", which is a method of loading/requesting extra data (pages) from the server through JS without reloading the page (just loading a new page in the background that the user sees as part of the same page).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The short answer to your question is yes.

    If this is a one time insertion as the page is loading, one way to debug it is to view the page or script (if it's an external script) in the browser. IE will not view external scripts, so use another browser if it's an external script.

    Anyways, viewing in the browser will, in the case of a page allow you to use the browser's 'view source'. This will show you how your asp token (<%=rs("pID")%>) is being served to the user. In the case of an external script, in just about any browser other than IE, navigating directly to the external script will show you how that script is being served.

    Once you see how the code is being served, it should be relatively easy to see what's causing the problem. In a case like this, often it's missing or extra quotation marks. But it could be numerous things.

    Remember, regardless of what asp token you use, it must resolve in the served code to fit what is expected in the javascript.

    If you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •