Create a simple page like
Default.aspx
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script language="Javascript">
function xmlhttpPost(strURL) {
// alert(strURL)
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {alert('hi');
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
function getquerystring() {
//var form = document.forms['f1'];
// var word = form.word.value;
// qstr = 'w=' + escape(word); // NOTE: no '?' before querystring
// return qstr;
}
function updatepage(str){
alert(str)
document.getElementById("result").innerHTML = str;
}
</script>
</head>
<body>
<form name="f1">
<p>word: <input name="word" type="text">
<input value="Go" type="button"
onclick='JavaScript:xmlhttpPost("http://localhost:2835/website1/WebService.asmx/HelloWorld")'></p>
<div id="result"></div>
</form>
</body>
</html>
Then Create a webservice
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
http://dotnetclassic.com/post/AjaxWithJavascript.aspx
Revision number 1, Tuesday, April 01, 2008 8:38:46 AM by m imran shafiq
You must Login to comment.
|
Fri, Sep 19, 2008 7:05 AM
by x-format
|
What do you mean by : "Ajax With Javascript" ?? Do you really know what AJAX mean?
|
|
Mon, Dec 22, 2008 10:26 PM
by agrawalbs
|
AJAX cant be without javascript (Asynchronous Javascript and XML) Btw nice article... I guess what you are trying to exhibit is also popular as javascript services
|
|
Fri, Oct 30, 2009 1:24 AM
by yrb.yogi
|
Good!
|
|
Fri, Jan 22, 2010 2:07 AM
by amanbhullar
|
Nice!!!
|
|
Thu, Jul 22, 2010 7:27 AM
by namratam
|
can somebody explian me why we are using-
WebService(Namespace:="http://tempuri.org/")> _
WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
|
New
Fri, Jul 18, 2008 7:06 AM
by
|
AJAX and CSS
Cascading Style Sheets (CSS) is one of the core technologies in the AJAX architecture apart from XML, DOM, JSON and so forth. Here are some links on using CSS with AJAX: Create flickr-like editing fields using AJAX and CSS/ 26 best ways to implement ajax css
|
Revision #14
Sat, Feb 27, 2010 8:52 AM
by
|
Javascript
JavaScript holds it all together on the client side. There are a number of extensions that have been made to improve and expand base JavaScript object functionality. Blog Posts Four ASP.NET AJAX JavaScript UI Methods You Should Learn: Dave Ward describes more
|
Revision #15
Sat, Feb 5, 2011 4:50 PM
by
|
AJAX
Asynchronous JavaScript and XML - It's Ajax and it's everywhere. Start at the ASP.NET Ajax site and work from there...there's a ton of resources at your disposal. Ajax Showcase - Check out some of the great sites that been built using Ajax. Ajax
|
New
Mon, Oct 3, 2011 7:50 PM
by
|
Jquery Cross-Domain ajax call using JSONP
Hi everyone. We all know the role of ajax and its implementation. We can use ajax in asp.net as well as in javascript/jquery. But there is a limitation of same origin policy. i.e. we can only use ajax to post and get requests within our site. We can call webservices
|