$('#BotAcceder').click(function(){ $('#FrmAcceso').submit(); return false; }); $('#FrmAcceso').submit(function(e){ e.preventDefault(); $.ajax({ type: "POST", url: "https://dataprius.com/amb.investor/", data: $(this).serialize(), datatype : 'html', success: function(data) { if(strStartsWith(data,"error:")) { var arrResult= data.split(":"); var msg=arrResult[1]; $("#TextoPopup").html(msg); $("#Popup").show(); } else { $("#ValCodigo").val(""); $("#TextoExito").html("Se redirige al area de Inversores en unos segundos."); $("#PopupExito").show(); } } }); return false; }); function strStartsWith(str, prefix) { return str.indexOf(prefix) === 0; }