Error when using jquery webservice call to populate dropdownlist

Posted by bugz on Stack Overflow See other posts from Stack Overflow or by bugz
Published on 2012-02-01T14:41:08Z Indexed on 2012/06/19 3:16 UTC
Read the original article Hit count: 155

Filed under:
|
|

For some reason when i tested parsing a json string to a dropdownlist it worked doing this

  var json = [{ "Id": "12345", "WorkUnitId": "SR0001954", "Description": "Test Service Request From Serena", "WorkUnitCategory": "ServiceRequest" }, { "Id": "12355", "WorkUnitId": "WOR001854", "Description": "Test Work Order From Serena", "WorkUnitCategory": "ServiceRequest" }, { "Id": "12365", "WorkUnitId": "DBR001274", "Description": "Test Database Related Service Request From Serena", "WorkUnitCategory": "ServiceRequest"}];

            $(json).each(function() { comboboxWorkUnit.append($('<option>').val(this.Id).text(this.WorkUnitId)); });

However when i tryed taking the json from my webservice and placing it into the dropdownlist i get an error saying the dropdownlist doesnt support this metod.

$.ajax({   
type: "POST",   
url: "Services/WorkUnitService.asmx/WorkUnit",   
data: "{'Number' : '" + Number.text()  + "','Id': '" + combobox.val() + "','workerType': '" + EmployeeType + "'}",   
contentType: "application/json; charset=utf-8",   
dataType: "json",   
success: function(json) {
$(json).each(function() { comboboxWorkUnit.append($('<option>').val(this.Id).text(this.WorkUnitId)); });

} }); 

I also tried which called the webservice method but through an error

  $.postJSON("Services/WorkUnitService.asmx/WorkUnitsForParAndPhase", "{'parNumber' : '" + parNumber + "','phaseId': '" + combobox.val() + "','workerType': '" + EmployeeType + "'}", function(data) {
        alert(data.toString()); 
        }); 

And i tryed this which never called the webservice

 $.getJSON('Services/WorkUnitService.asmx/WorkUnitsForParAndPhase' + parNumber + '/' + combobox.val() + '/' + EmployeeType,
    function(myData) {
        alert(myData.toString());
    });

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about web-services