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('<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...