Loading variables from ASP to Flash 8 not working when ASP file contains HTML tags... why?

Discussion in 'Flash/Shockwave' started by sawtontape, Jan 30, 2007.

  1. Hello,

    I am trying to load variables using LoadVars() in my login page; if the only thing I am doing inside of my asp code is loading and sending variables to and from flash then everything is working, but as soon as I add any html tags into my asp code the variables return 'undefined'.... to me that is really strange, I've tried searching this online for about 2 hours now with different search words and nothing regarding this issue comes up...
    Has anyone had that problem before?
    I can actually take out most of the html tags from my asp file except the #include lines, well I guess I can copy pastethe functions that I need from included files too but there is got to be a better way of doing this, I'd really hate to break up all of my include files and copy paste separate functions everywhere, thatsredundant..
    Here's the code that I am usingin flash:

    submit.onPress = function(){
    var Login:Number;
    result_login.Login = 1;
    result_login.UserName = UserName;
    result_login.Password = Password;
    result_login.sendAndLoad("login.asp", result_login, "POST")
    }
    var result_login = new LoadVars();

    result_login.onLoad = function() {
    alert = result_login.R;
    };
    stop();

    And here isour ASP code:

    <%
    Option Explicit

    Dim UserName
    Dim Password
    Dim Login
    Dim ReturnString
    UserName = Trim(Request.Form("UserName"))
    Password = Trim(Request.Form("Password"))
    Login = Trim(Request.Form("Login"))

    ReturnString = "R=this works!!! " &amp; UserName &amp; Password &amp; Login
    response.Write(ReturnString)

    %>

    now the code above works perfectly! but as soon as I add more things to my asp file any HTML tags or include, the variables in flash return 'undefined'... :
    Example of ASP code thatDOESNT work:
    <% Option Explicit %>
    <!-- #include file = "../dbfunctions2.asp" -->
    <!-- #include file = "/includes/newarticle.asp" -->
    <%
    Option Explicit

    Dim UserName
    Dim Password
    Dim Login
    Dim ReturnString
    UserName = Trim(Request.Form("UserName"))
    Password = Trim(Request.Form("Password"))
    Login = Trim(Request.Form("Login"))

    ReturnString = "R=this works!!! " &amp; UserName &amp; Password &amp; Login
    response.Write(ReturnString)

    %>

    Please help me out if you know what could be wrong, I dont know what internal processes flash goes to when it sends things to asp or how long it waits for the response from ASP but it seems to me like as soon as flash sees HTML tags it doesn't look any further to see if there is anything returned back and sets the vars to undefined or maybe it just times out, I guess I just dont know...

    Thanks in Advance,

    Post Edited (sawtontape) : 1/31/2007 12:56:45 AM GMT
     
  2. Ok, well the good news is that I've screwed up with my #include file code line if you look bellow:
    <!-- #include file = "/includes/newarticle.asp" -->

    the code above shouldnt have the '/' before includes (this is correct):
    <!-- #include file = "includes/newarticle.asp" -->

    It was very frustrating to find that but, well now everything is working! [​IMG]

    The sort of strange thing though is if I put <html> </html> tags in the begining and end of my .asp file nothing works again! But who cares, I dont need those tags anyway.. [​IMG]
     
  3. Keep in mind you don't always want to use "file", at times you will want/need to use "virtual".


    i.e. <!-- #INCLUDE virtual=""/includes/newarticle.asp" -->


    And don't use the HTML tags in your include files if the server already created the doctype for you in the page.
     

Share This Page