Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Trying to get external page to pass variable back ...

  1. #1
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trying to get external page to pass variable back ...

    I tried the iFrame example. My issue is that I'm executing an external javascript from an asp page. The result that I need back in ASP is in Javascript. I know the typical answer is to set a hidden form variable and reload the page. I can't reload the page because of it's complexity. I somehow need to seemlessly get the value back so that my ASP page can continue on the appropriate path depending on the result.

    Can I do this with DHTML?
    Please advise. The iFrame example did execute my code, but I still wasn't able to save my result, only display stuff.

    Thanks.
    Melissa

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Sounds to me as if you need to use AJAX. Google for tutorials on the subject.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I looked at this briefly and am somewhat familiar, since my external page is actually using the xmlhttp object and this method to handle something else.
    I have a javascript function that calls a server side asp page. Data is returned and left back in the javascript function.

    If AJAX requires the calling script to be javascript, I still can't seem to get my result in ASP without storing it in some form variable.

    Am I missing something?

    Melissa

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes. If you use AJAX to access, for example,
    Code:
    asppage.asp?var1=val1&var2=val2
    ... you can read off the GET variables on the ASP page. POST variables are possible too, by way of send().
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, I'm still not following.

    My 1st ASP page calls a JavaScript function that uses xmlhttp to call a different ASP page. The result is set in the 2nd asp page and passed back to the JavaScript function. I need the result to be accessed by the 1st ASP page. I am passing variables as you mention in the javascript that are being accessed by the 2nd ASP page. But again -- I need this accessed by the 1st ASP page.

    Thanks.
    Melissa

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    OK. Let's very originally call your pages one.asp and two.asp.
    • one.asp uses XMLHttpRequest to request two.asp, passing the data using GET or POST.
    • two.asp outputs the result.
    • one.asp then uses AJAX to request itself, passing that data.
    Of course, it would be even easier to just call one.asp straight from two.asp.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok.
    I think the problem is more that I really don't want to reload one.asp. I have a very complicated form filled out that has already been submitted. If I have to recall one.asp from two.asp, then I'll need to pass in all completed fields, which is what I was hoping to avoid.

    If I'm going to do that, then I might as well have my javascript or two.asp page resubmit the form to get my result.

    I hope I'm still not missing it!! :/

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I hope I'm still not missing it!! :/
    You are. The whole point of using XMLHttpRequest is to avoid reloading the page There's no need to.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok.
    I think I've got it. I just need to go ahead and give it a shot.

    Thanks -- you may be hearing from me again.


    Melissa

  10. #10
    Join Date
    Jun 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried a new test by having one.asp call two.asp. One.asp has a simple form. Two.asp sets a value and then passes it back. I tried both having the javascript call itself on one.asp and also having two.asp call one.asp.

    In both cases, when one.asp is called again - no matter what method - my form data is wiped out. Is the only way around this to pass all my form data to two.asp and then pass it back? This is what I was trying to avoid because of a lot of my form and form data are generated dynamically based on what the user selected along the way.

    The form in one.asp looks like:
    <form>
    <input type=text name="txt" value="">
    <input type=button onClick="CallTwo();" name="btn" value="Click">
    </form>

    And for now two.asp just does a response.redirect to one.asp passing a variable. Should I try to open the two.asp in a new window so that one.asp's form is left intact?

    Thanks.
    Melissa

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
  •