0

Hello I have this problem, I want to pass my picture and save it on database through AJAX but, it isn´t working, I have to different combination in javascript

function nahraj(){
    var text =  $('#subor').val();
    $.post( "aktualizuj.php", {
            'subor':text

        }, function (data) {
            $('#result').html(data);

        }


    );

}

this one works but after I send it I am getting a road to my picture as : C:/fakepath/picture.jpg So I thougt that I should set an enctype there so I search a way how to do it, I found something and I make something like this :

 function nahraj(){
            var text =  $('#subor').val();
            $.post.enctype("multipart/form-data").( "aktualizuj.php", {
                    'subor':text

                }, function (data) {
                    $('#result').html(data);

                }


            );

        }

but this version doesn´t do anything so it does not work, what am I doing wrong ?

eraz
  • 57
  • 9
  • See http://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax – The Muffin Man Jan 04 '16 at 20:30
  • I tried to copy it to my method, but it doesn´t work... I am really new one to the javascript and ajax thing, this one I wrote along with tutorial and now I am only trying to edit or something for different stuff – eraz Jan 04 '16 at 20:39
  • You need to go read the documentation for jquery. `$.post` is just shorthand for `$.ajax` and you can't set the content type in $.post, so you must use $.ajax. Aside from that in your second example your javascript syntax is wrong.. it looks like you just need to do some more research and come back if you have specific questions. As of now you're giving us a wide arching problem when in reality there's a dozen issues here. We'll help you with a specific issue, but in this case it would require us do it all for you. – The Muffin Man Jan 04 '16 at 20:47

0 Answers0