Using Python Blobstore API with ajax

is there any sample showing how to use apb blobstore with ajax?

when I use forms, it works fine, but if I use jquery, I don’t know how to submit the file, and I get this error:

    blob_info = upload_files[0]
    IndexError: list index out of range

I have this code in javascript

function TestAjax()
{
 var nombre="Some random name";
 ajax={
    type: "POST",
    async:true,
    //dataType:"json",
    url:"{{upload_url}}",
    data:"nombreEstudio="+nombre,   
    error: function ()
    {
        alert("Some error");
        $("#buscando").html("");
    },            
    success: function()
             { alert("it ok") }
 };             
 $.ajax(ajax);
}

When I use forms, the file that he submitted is with an input tag (just like a sample document)

+3
source share
2 answers

I wrote a series of posts about this.

+4
source

- ... , , , <form> - : enctype = "multipart/form-data", ?

"POST" ajax, , .

jQuery "ajax file upload", .

, !

** **

, , , - , , ajax ( ) iframe iframe JavaScript.

+2

Source: https://habr.com/ru/post/1752320/


All Articles