I have aspx page with the code behind file.
In the aspx page i have some html content and java script.
I making a request to the aspx page in the page_load in the aspx i am doing some operation and returning the response as Response.Write("response string").
I observed that it's throwing error as invalid json and in the response body i total aspx content is getting added along with the response i want to throw.
Any idea what i am doing wrong?
What I have tried:
my Test.aspx.vb page
========================
Partial Class HostBudget
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
result = singleCopy.ValidateTemp()
Response.Write(JsonConvert.SerializeObject(result))
End Sub
End Class
My Test.aspx page contains
Html content and javascript functions.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb"
Inherits="HostBudget" %>
<!DOCTYPE html>
<html>
<head runat="server">
</head
<body></body></html>
<script>
Some js functions.
</script>
My ajax function call
========================
$.ajax({
type: "GET",
url: "../../HostBudget/Test.aspx,
dataType: "json",
success: function (response) {
if (response.length > 0)
alert(response)
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
CheckForAjaxError(XMLHttpRequest);
}
});
It's returning the response along with the aspx page content. error it's throwing as Invalid Json
Any idea what i am doing wrong?