Note that there are some explanatory texts on larger screens.

plurals
  1. POJSONP json callback method not called : parsererror
    primarykey
    data
    text
    <p>I have the following ajax function using jsonp:</p> <pre><code> function PopulateDivisions1() { $.support.cors=true; $.ajax({ type:'GET', url:'http://IP/Service/api/DivisionSearch/GetAllDivisions?callback=?', dataType: "jsonp", //jsonp: false, jsonpCallback: "myJsonMethod", success: function(data) { alert('yes'); $("#divisionSelect").append($('&lt;option&gt;&lt;/option&gt;').val("-99").html("Select One")); $.each(data, function(i, item){ $("#divisionSelect").append($('&lt;option&gt;&lt;/option&gt;').val(item.Name).html(item.Name)); }); }, error: function(xhrequest, ErrorText, thrownError) { alert("Original: " + thrownError + " : " + ErrorText); } }); } </code></pre> <p>I am getting the following error: myJsonMethod was not called : parsererror</p> <p>If I look at Fiddler, I am getting the following data back, I added the callback name to the front, as I saw that suggested, if I take it out it still doesn't work.</p> <pre><code> "myJsonMethod([{\"Id\":1,\"Description\":\"Executive\",\"Name\":\"Executive \"},{\"Id\":2,\"Description\":\"ASD\",\"Name\":\"Administrative Services Division \"},{\"Id\":3,\"Description\":\"COM\",\"Name\":\"Communications \"},{\"Id\":4,\"Description\":\"CP\",\"Name\":\"Contracts and Procurement \"},{\"Id\":5,\"Description\":\"PMD\",\"Name\":\"Program Management Division \"},{\"Id\":6,\"Description\":\"RED\",\"Name\":\"Research and Evaluation Division \"},{\"Id\":7,\"Description\":\"IT\",\"Name\":\"Information Technology \"}])" </code></pre> <p>Here is the method in my controller:</p> <pre><code> public string GetAllDivisions(string callback) { var divisions = _DivisionModel.GetAllDivisions(); var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string json = serializer.Serialize(divisions); string result = callback + "(" + json + ");"; return result; } </code></pre> <p>I'm not getting to my success call, what am I missing or doing wrong?</p>
    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.
    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