Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).on('click', '#registracijaBtn', function(e){
- e.preventDefault();
- if(validateForm()){
- $.ajax({
- url: ajaxValidacija,
- type: "POST",
- data: JSON.stringify({
- "korisnickoIme": $('#un').val(),
- "lozinka": $('#pw').val(),
- "ime": $('#ime').val(),
- "prezime": $('#prezime').val(),
- "telefon": $('#telefon').val(),
- "email": $('#email').val(),
- "avatar": "linkDoSlike",
- "blokiran": false,
- "administrator": false,
- }),
- contentType: "application/json; charset=utf-8",
- dataType: "text",
- success: function(data){
- if(data=="true"){
- var reader = new FileReader();
- var files = $('#slika').prop("files")
- var file = files[0];
- reader.onload = function(e){
- $.ajax({
- url: ajaxUploadSlike,
- type: "POST",
- data: JSON.stringify({
- "korisnickoIme": $('#un').val(),
- "image": e.target.result
- }),
- contentType: "application/json; charset=utf-8",
- dataType: "text",
- success: function(data){
- toastr.success("Uspešno ste se registrovali", "Potvrda");
- $(location).attr('href', loginPage);
- }
- })
- }
- reader.readAsDataURL(file);
- }else{
- toastr.error("Vec postoji korisnik sa takvim korisničkim imenom.", "Greška");
- }
- },
- error: function(){
- toastr.error("Registrovanje nije bilo uspešno", "Greška");
- }
- });
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment