TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Saravanan Ponnusamy
363
4.5k
1.1m
ASP.Net AJAX-- how to display ajax response in html
May 10 2018 8:37 AM
my code:
$(document).ready(
function
() {
$(
"[id*=Aspx_Dropdown_Back]"
).change(
function
() {
$.ajax({
type:
"POST"
,
url:
"View.aspx/GetVariables"
,
data:JSON.stringify({
"xszBack"
: document.getElementById (
"<%= Aspx_Dropdown_Back.ClientID %>"
).value}),
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
,
success: OnSuccess,
failure:
function
() {
alert(
"F"
);
}
});
});
});
function
OnSuccess(data) {
var
msg = data.hasOwnProperty(
"d"
) ? data.d : data;
$(
"#divToAddTo"
).empty();
$(
"#divToAddTo"
).html(msg);
}
code behind:
[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet =
false
)]
public
static
string
GetVariables(
string
xszBack)
{
string
Retrunstring =
""
;
Retrunstring =
"<asp:TextBox ID='TextBox31' runat='server' CssClass='TextBox_Text12' Width='250' />"
;
return
zszRetrunstring;
}
im trying to get string(HTML string) from code behind function and display in DIV tag by using ajax reponse data.
but i cant do that.. no error raising..
if i given that HTML string directly in AJAX Success methos,, like below..
function
OnSuccess(data) {
var
$msg = data.hasOwnProperty(
"d"
) ? data.d : data;
$(
"#divToAddTo"
).empty();
//$("#divToAddTo").html($msg);
$(
"#divToAddTo"
).html(
'<asp:TextBox ID="TextBox11" runat="server" CssClass="TextBox_Text12" Width="250" /><br/><asp:TextBox ID="TextBox21" runat="server" CssClass="TextBox_Text12" Width="250" /><br/>'
);
}
its working fine... and two textbox's are generated inside DIV tag.
but the string, same string which i get from code behind.. its not working..
pls. dont refer any web reference... pls. give any code..
thanks all...
Reply
Answers (
3
)
MVC Data Entity Framework
Logoff When we change Url parameter intger to string