javascript - Ajax alert on success response not working c# -
javascript - Ajax alert on success response not working c# -
i have piece of code inserts contact details using ajax , c# code runs through , db updated record alert box success doesnt seem show. seem work if debug through javascript debugger in chrome, nail piece of code , alert show. not otherwise.
here code:
javascript
function insertdonator() { var title = $("#dropdowntitle option:selected").text(); var firstname = $("#txtfirstnameinput").val(); var lastname = $("#txtlastnameinput").val(); var add1 = $("#txtadd1").val(); var add2 = $("#txtadd2").val(); var town = $("#txttown").val(); var county = $("#txtcounty").val(); var postcode = $("#txtpostcode").val(); var telephone = $("#txtphoneinput").val(); var email = $("#txtemailinput").val(); var collectionarea = $("#txtcollectionareainput").val(); $.ajax({ type: "post", url: "webservice1.asmx/insertdonator", data: '{title:"' + title + '", firstname: "' + firstname + '",lastname:"' + lastname + '", add1:"' + add1 + '", add2: "' + add2 + '",town:"' + town + '",county:"' + county + '",postcode:"' + postcode + '",telephone:"' + telephone + '",email:"' + email + '",collectionarea:"' + collectionarea + '"}', contenttype: "application/json; charset=utf-8", datatype: "json", success: onsuccess, failure: function (response) { apprise(response.d); } } ) } function onsuccess(response) { alert("record added"); } html (aspx file)
<asp:button id="btnaddrecord" runat="server" text="add donator" onclientclick="insertdonator();" />
you not cancelling default action of button click. can utilize preventdefault(), can retrun false in click event.
onclientclick="insertdonator(); homecoming false;" javascript c# jquery ajax
Comments
Post a Comment