I am getting
ReferenceError: data is not defined and
>NetworkError: 500 Internal Server Error - http://localhost/WebApplication2/js/test.aspx"
But my aspx page is in right directory
I did all these to remove internal server error :
http://pcsupport.about.com/od/findbyerrormessage/a/500servererror.htm
Code is as per tutorial
Index.html (Callback Data will be posted Here)
<body>
<input id="button" type="submit" value="Go" />
<div id="feedback"> </div>
</body>
this is My Ajax method :
$('#button').click(function () {
$.ajax({
type: "POST",
url: "test.aspx",
data: {"name=" + name},
success: function (data) {
$("#feedback").html(data);
}
});
});
test.aspx
<form id="form1" runat="server">
<div>
<%Response.Write(Request.Form["name"].ToString()); %>
</div>
</form>
similar Posts :
ajax and “Uncaught ReferenceError: data is not defined”
$.ajax() and "Uncaught ReferenceError: data is not defined"
Ajax data - Uncaught ReferenceError: date is not defined
Edit : JSLint /JSHint /SharpLinter still not helping much for detecting syntax Error .I need some suggestion for syntax check
there were issue of placing datatype parameter too.. it is not in my case .
I could not able to find something simple there..Please suggest
I guess, you should pass data as:
data: {name: name},
Also, instead of data
, try to use some other variable in the success function:
success: function (response) {
$("#feedback").html(response);
}
ok ..Finally got it working ... error was in data parameter (after url)
Instead of (this is tutorial Code)
data: {"name=" + name1},
this worked for me
data : {'name':name1},
Here is working Code :
script
$('#button').click(function () {
var name1="aa";
$.ajax({
type: "POST",
url: "test.aspx",
data : {'name':name1},
statusCode: {
404: function () { $("#messege").text("Page not found"); },
500: function () { $("#messege").text("internal server error"); }
},
success: function (data) {
$("#messege").html(data);
} });
});
rest is same .Below link was relevant and helpful
jquery POST data in aspx page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With