Reputation: 4222
This is my JQuery code -
$("#test_link").click(function() {
jQuery.ajax({
type: "POST",
url: "http://localhost:8882/Hello.aspx",
data: '',
cache: false,
success: function(response)
{
alert(response);
}
});
});
Hello.aspx simply prints 'Hello World'. When I click on the link it shows a alert with the following response -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Hello World</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
Hello World
</body>
</html>
Ideally it should just 'print Hello World'
Upvotes: 1
Views: 423
Reputation: 11
you should remove all contents in your hello.aspx file and let only one string that you want to get in yr response. Remove all html tags or try to use the Response.WriteLine("hello world") in the page_load method (see the associated code behind file)
Upvotes: 1
Reputation: 2727
Maybe your client test page an the HelloWorld.aspx are on different ports or use a different URL? Try using a jsonp attribute.
jsonp: true
Upvotes: 1
Reputation: 2655
You are using a POST to post the data to hello.aspx. Maybe that is forbidden?
If you are only loading data you can simply use JQuery get in stead of the full Jquery AJAX call: http://api.jquery.com/jQuery.get/
Upvotes: 0