Ajax or Asynchronous JavaScript and XML is a web development technique that used XMLHttpRequest object to provide us a way to communicate with a server after a web page has loaded.
What Ajax or XMLHttpRequest object can do?
- Update a web page with new data without reloading the page
- Request data from a server after the page has loaded
- Receive data from a server after the page has loaded
- Send data to a server in the background
Working of AJAX with VB
Here’s how to used XMLHttpRequest object in visual basic to get data directly from web server.
Outside variable declaration
public vbAjax As Object
Build public function
public function AjaxRequest(url as string)
'set object
Set vbAjax = CreateObject("Microsoft.XMLHTTP")
If Not vbAjax Is Nothing Then
vbAjax.open "GET", url, False
vbAjax.send (Null)
'4 = "loaded"
If vbAjax.readyState = 4 Then
'200 = OK
If vbAjax.Status = 200 Then
'our code here...
MsgBox "STATUS: " & vbAjax.Status & vbNewLine & vbNewLine & "STATUSTEXT: " & vbAjax.statusText & vbNewLine & vbNewLine & vbAjax.responseText
Else
MsgBox "Problem retrieving XML data"
End If
Else
MsgBox "Not Ready"
End If
End If
Set vbAjax = Nothing
end function
calling the function
call AjaxRequest("http://www.w3schools.com/XML/note.xml")
RESOURCES :

{ 1 trackback }
{ 0 comments… add one now }