Note that there are some explanatory texts on larger screens.

plurals
  1. POError while calling jQuery AJAX call to an ASP.NET WebMethod
    primarykey
    data
    text
    <p>I have to make a ajax call to an ASP.NET WebMethod.I've wrtiten the following code for doing that and tested whether ajaxcall is working properly by putting alert in both success and error function.I am getting alert as error and could not find where i have gone wrong.</p> <p>Here's my code</p> <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Multiple_Markers.aspx/BindAddress", data: "{}", dataType: "json", success: function(data) { alert("success") }, error: function(result) { alert("Error"); } }); }); &lt;/script&gt; </code></pre> <p>Here's my webmethod written in Multiple_Markers.aspx page.The webmethod is working perfectly.</p> <pre><code>[WebMethod] public static OrganizationBAL[] BindAddress() { DataTable dt = new DataTable(); List&lt;OrganizationBAL&gt; lstAddress = new List&lt;OrganizationBAL&gt;(); ProgramDAL clsPgmDAL=new ProgramDAL(); using (SqlConnection sqlcon = new SqlConnection(clsPgmDAL.connStr)) { string str="select street_address as title,latitude as lat,longitude as lng,"+ "street_address+','+city+','+state+','+country as descritpion from dbo.tblOrganization_Address"; using (SqlCommand cmd = new SqlCommand(str, sqlcon)) { sqlcon.Open(); SqlDataAdapter sqlad = new SqlDataAdapter(cmd); sqlad.Fill(dt); foreach (DataRow dRow in dt.Rows) { OrganizationBAL clsOrg = new OrganizationBAL(); clsOrg.CITY = dRow["title"].ToString(); clsOrg.LATITUDE = dRow["lat"].ToString(); clsOrg.LONGITUDE = dRow["lng"].ToString(); clsOrg.ADDRESS_TYPE_LOCATION = dRow["descritpion"].ToString(); lstAddress.Add(clsOrg); } } } return lstAddress.ToArray(); } </code></pre> <p>The webservice i have written to achieve the above result.But the problem still persists.</p> <pre><code> [WebMethod] [ScriptMethod(ResponseFormat=ResponseFormat.Json)] public OrganizationBAL[] BindAddress() { DataTable dt = new DataTable(); List&lt;OrganizationBAL&gt; lstAddress = new List&lt;OrganizationBAL&gt;(); ProgramDAL clsPgmDAL = new ProgramDAL(); using (SqlConnection sqlcon = new SqlConnection(clsPgmDAL.connStr)) { string str = "select street_address as title,latitude as lat,longitude as lng," + "street_address+','+city+','+state+','+country as descritpion from dbo.tblOrganization_Address"; using (SqlCommand cmd = new SqlCommand(str, sqlcon)) { sqlcon.Open(); SqlDataAdapter sqlad = new SqlDataAdapter(cmd); sqlad.Fill(dt); foreach (DataRow dRow in dt.Rows) { OrganizationBAL clsOrg = new OrganizationBAL(); clsOrg.CITY = dRow["title"].ToString(); clsOrg.LATITUDE = dRow["lat"].ToString(); clsOrg.LONGITUDE = dRow["lng"].ToString(); clsOrg.ADDRESS_TYPE_LOCATION = dRow["descritpion"].ToString(); lstAddress.Add(clsOrg); } } } return lstAddress.ToArray(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload