Jump to content

Xmlhttprequest Issues

Recommended Posts

EDIT: Solved the problem a totally different way. All's well :)

I'm writing a program in VB.NET that uses basic page scraping and authentication to get some information from a web site. Normally you would log in to the site using your browser and it would display some info on the page, but I'm trying to obtain this information programatically. The problem I've run into is that a lot of the information that is displayed is obtained using JQuery and AJAX. I can log in and authenticate perfectly fine using the HTTPWebRequest class, but I can't figure out how to, nor can I find anywhere that will help me figure out how to format and send an XMLHTTPRequest using either a VB.NET class specifically for it, or using the functionality of the HTTPWebRequest class.

Basically, I've got a request that looks like this:

$('lyr_friend').innerHTML = jQuery.ajax({type:"GET", url:"/some/place", data:{gameUid:"189345",charID:"9153",serverID:"4",charStatus:"true"}, async:false}).responseText;

I need to figure out how to make that request in VB.NET. Obviously I can't use POST data (which is how I log in and obtain a session cookie) because it uses GET as the method, right? So how do I pass this data along with the request? I'm going to try using a StreamWriter, but I doubt it will work, even if simply because I don't know how to format the data.

Anybody know anything that could help me out? Thanks in advance :)

Edited by Kerberos
Link to comment
Share on other sites

  • 1 month later...

XmlHttpRequest objects function the same exact way as any normal HTTP request does. Your problem is not with the difference between XHR and HTTP Requests, it relates to the actual request itself.

The problem you are hitting is how exactly does data get passed in GET Request to a server as opposed to a POST.

There is a big difference between the two:

GET Requests:

-request parameters are sent inside of the request URI as a key-value pair after the query symbol (?), e.g. /resource?foo=bar

POST Requests:

-request parameters are sent in the body of the HTTP request (which the OP learned how to do in VB). In Java (the language I am most familiar with), the "request body" is sent in an HTTP Request as an "Entity" object, most often a StringEntity.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...