Using Microsoft.XMLHTTP causes all GET values to revert to "0"

Discussion in 'ASP General' started by Phil Powell, Jul 25, 2005.

  1. Phil Powell

    Phil Powell Guest

    [ASP]
    'GET THE HTML CONTENT FOR DISPLAY BAND ORIGIN
    Dim bandOriginDropdown
    On Error Resume Next
    set scraper = Server.CreateObject("Microsoft.XMLHTTP")
    if err then
    bandOriginDropdown = ""
    else
    scraper.open "GET", path &
    "/includes/soa_form_element_plugin.inc.asp", false
    scraper.send "tableID=2&fieldID=1&typeID=0"
    bandOriginDropdown = scraper.ResponseText
    set scraper = nothing
    end if
    [/ASP]

    This is a code snippet based upon a scrape on an included ASP script I
    wrote that is designed to produce dynamically generated HTML form
    element material based upon query string values that are read into
    globally-included arrays:

    [ASP]
    Dim tableNameArray(2)
    tableNameArray(0) = "event"
    tableNameArray(1) = "gb"
    tableNameArray(2) = "bands"

    Dim fieldArray(4,2)
    fieldArray(0,0) = "event_name"
    fieldArray(0,1) = "event_date"
    fieldArray(0,2) = "event_text"
    fieldArray(1,0) = "last_name"
    fieldArray(1,1) = "url"
    fieldArray(1,2) = "fave_bands"
    fieldArray(2,0) = "bandStyle"
    fieldArray(2,1) = "bandOrigin"
    fieldArray(2,2) = "bandDescription"

    Dim formElementTypeArray(3)
    formElementTypeArray(0) = "dropdown"
    formElementTypeArray(1) = "text"
    formElementTypeArray(2) = "textarea"
    formElementTypeArray(3) = "hidden"
    [/ASP]

    Here is the ASP script soa_form_element_plugin.inc.asp:

    [ASP]
    <!--#include virtual=/soa/includes/val_global_vars_functions.asp -->
    <%
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' file: soa_form_element_plugin.inc.asp
    '
    ' created by: Phil Powell on 7/24/2005 '
    ' '
    ' Produce a dropdown list of band-related items whereby the '
    ' Request.QueryString collection object determines which field '
    ' you will obtain and data to produce into an HTML form '
    ' element type dictated by global variables tableNameArray and '
    ' fieldArray '
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Dim myField, formElementType
    if IsNumeric(Request.QueryString("tableID")) then tableName =
    tableNameArray(Request.QueryString("tableID"))
    if IsNumeric(Request.QueryString("tableID")) and
    IsNumeric(Request.QueryString("fieldID")) then
    myField = fieldArray(Request.QueryString("tableID"),
    Request.QueryString("fieldID"))
    end if
    if IsNumeric(Request.QueryString("typeID")) then myElementType =
    formElementTypeArray(Request.QueryString("typeID"))

    Response.Write("tableID = " & Request.QueryString("tableID"))

    if not IsNull(myField) and myField <> "" and not IsNull(tableName)
    and tableName <> "" then


    Dim Conn, rs
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
    Server.MapPath("\soa\db\sub.mdb")

    sql = "SELECT DISTINCT " & myField & " " &_
    "FROM " & tableName & " " &_
    "WHERE " & myField & " IS NOT NULL" &_
    " AND " & myField & " <> '' " &_
    "ORDER BY " & myField & " ASC"

    set rs = Conn.execute(sql)


    if strcomp(lcase(myElementType), "text") = 0 then
    %>
    <input name="my_<%= myField %>" size="50" maxlength="255" value="<%=
    Replace(Request.Form("my_" & myField), """", "&quot;") %>">
    <%
    elseif strcomp(lcase(myElementType), "textarea") = 0 then
    %>
    <textarea name="my_<%= myField %>" rows="8" cols="40"><%=
    Replace(Request.Form("my_" & myField), "<", "&lt;") %></textarea>
    <%
    elseif strcomp(lcase(myElementType), "hidden") = 0 then
    %>
    <input type="hidden" name="my_<%= myField %>" value="<%=
    Replace(Request.Form("my_" & myField), """", "&quot;") %>">
    <%
    elseif strcomp(lcase(myElementType), "dropdown") = 0 then
    %>

    <select name="my_<%= myField %>">
    <option value="">Choose From Below:</option>
    <option value="">------------------</option>

    <%
    do until rs.eof
    %>

    <option value="<%= rs("" & myField & "") %>"<%

    if strcomp(Request.Form("my_" & myField), rs("" & myField & "")) =
    0 then Response.Write(" selected")

    %>><%= rs("" & myField & "") %></option>

    <%
    rs.moveNext
    loop
    set rs = nothing
    %>

    </select>

    <%
    end if ' END OF FORM ELEMENT TYPE SELECTION

    end if ' END OF DISPLAY

    Conn.Close
    set Conn = nothing
    %>
    [/ASP]

    Sorry so much code, but there is no way I can think of to explain my
    problem.

    Here is the output of the Response.Write:

    However, if I call the URL directly

    http://www3.brinkster.com/soa/includes/soa_form_element_plugin.inc.asp?tableID=2&fieldID=1&typeID=0

    This is what I get:

    Could someone help me with this one? It's live and broken and I can't
    fix it (up until 4:30am on this and have had no luck fixing it)

    Thanx
    Phil
    Phil Powell, Jul 25, 2005
    #1
    1. Advertising

  2. Phil Powell wrote:

    > [ASP]
    > 'GET THE HTML CONTENT FOR DISPLAY BAND ORIGIN
    > Dim bandOriginDropdown
    > On Error Resume Next
    > set scraper = Server.CreateObject("Microsoft.XMLHTTP")
    > if err then
    > bandOriginDropdown = ""
    > else
    > scraper.open "GET", path &
    > "/includes/soa_form_element_plugin.inc.asp", false
    > scraper.send "tableID=2&fieldID=1&typeID=0"


    A HTTP GET request does not have a request body so it makes no sense to
    pass anything to the send method if you do open "GET".
    If you want to pass values with a GET request then the only way is to
    use the query string part of the URL e.g.
    scraper.open "GET", path &
    "/includes/soa_form_element_plugin.inc.asp" &
    "?tableID=2&fieldID=1&typeID=0"
    Then soa_form_element_plugin.inc.asp can read out
    Request.QueryString("tableID")
    for instance.

    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jul 25, 2005
    #2
    1. Advertising

  3. Phil Powell

    Phil Powell Guest

    Thanx that's what I wound up trying last night for it to work. Please
    explain why HTTP GET request does not have a request body yet HTTP POST
    apparently does. They are both HTTP-based collection objects, so they
    should both have a request body, just in different formats, one via the
    URL and the other via an HTTP POST method.

    Phil
    Phil Powell, Jul 25, 2005
    #3
  4. Phil Powell wrote:

    > Please
    > explain why HTTP GET request does not have a request body yet HTTP POST
    > apparently does. They are both HTTP-based collection objects, so they
    > should both have a request body, just in different formats, one via the
    > URL and the other via an HTTP POST method.


    Look into the HTTP specification, a HTTP GET request does not have a
    request body, it consists solely of the request line and the request
    headers.
    POST or PUT requests have a request body.

    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jul 25, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    1
    Views:
    1,326
    smith
    Dec 8, 2004
  2. SpamProof
    Replies:
    0
    Views:
    533
    SpamProof
    Oct 21, 2003
  3. Chris Lewis
    Replies:
    6
    Views:
    1,057
    =?Utf-8?B?U2FtIE1pbGxlcg==?=
    Nov 8, 2004
  4. Replies:
    4
    Views:
    298
    Bob Barrows [MVP]
    Sep 22, 2006
  5. yawnmoth

    Msxml*.XMLHTTP vs. Microsoft.XMLHTTP

    yawnmoth, Nov 7, 2006, in forum: Javascript
    Replies:
    11
    Views:
    374
    Matt Kruse
    Nov 9, 2006
Loading...

Share This Page