javascript - Jquery ajax function not being called -


i have web page fill's form data based on json data sent web service. once form ready submitted function called takes form data turns xml-formatted string parses xml becomes valid xml object. problem happens, once data turned xml post data web service database can updated. using $.ajax() function post data, neither success nor error function within ever called. lead's me believe ajax function never being called or run. below code snippets:

submit button form:

<input type="submit" name="submitbutton" id="submitbutton" value="submit" onclick="postdata()"/> 

postdata function:

function postdata()         {             //gathering inputs             var cb = document.getelementbyid('paymentlist');             var selected_cb = cb.options[cb.selectedindex].text;             var pguid = getparameterbyname('guid');             var xmlstring = '<string>' +             addfield('approver', $('#approver').val()) +             addfield('companyname', $('#companyname').val()) +             addfield('emailaddress', $('#emailaddress').val()) +             addfield('address1', $('#address1').val()) +             addfield('address2', $('#address2').val()) +             addfield('city', $('#city').val()) +             addfield('province', $('#province').val()) +             addfield('country', $('#country').val()) +             addfield('postalcode', $('#postalcode').val()) +             addfield('phonenumber', $('#phone').val()) +             addfield('paymentmethod', selected_cb);              //gathering table data             xmlstring+='<contractdata>';             $('#table tbody tr:has(img[src="images/checkmark.png"])').each(function() {               xmlstring += '<contract>' + addfield('vendorpart', $('td:eq(1)', this).text()) +                     addfield('description', $('td:eq(2)', this).text()) +                     addfield('price', $('td:eq(3)', this).text()) +                     addfield('quantity', $('td:eq(4) input', this).val()) + '</contract>';             });               xmlstring += '</contractdata></string>';          //hard coded var purpose of example, web service name              var properid = 'somedata';              xmldoc = $.parsexml( xmlstring );             $xml = $( xmldoc );              //this function believe never run neither alerts below posted             $.ajax({                  type: "post",                  url: "http://www.webservice.com/service.asmx/sendmemydata",                  data: {properdata:properid, xml: $xml},                  datatype: "text",                  success: function() {                      alert("posted");                  },                  error: function ()                  {                     alert("error");                  }             });          } 

addfield function (just know when it's called in postdata()):

function addfield(name, value) { // add single element , value           value = value.replace(/&/g, '&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');           return '<' + name + '>' + value + '</' + name + '>';     } 


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -