How to change ajax URL on preUpload?
How to change ajax URL on preUpload?

I need to send ajax submits to a different url than ajax uploads.
This is because in combination with wordpress the standard ajax submits go to ajax-admin.php, while async uploads go to async-upload.php
Now the editor has the url attribute set like this:
ajax: {
url: ajax.ajax_url
}
now i try with
editor.on( 'preUpload', function ( e, fieldName, file, data) {
// i try to override the URL where the AJAX is sent to
// from ajax.ajax_url to ajax.upload_url
} );
i tried to set it with "e.url = ajax.upload_url", "e.target.href = ajax.upload_url, data.url = ajax.upload_url",".
Non of this worked.
So, my question is: how can i change the URL in the "preUpload" or is there another way how i can change the URL based on if it's submitting or async uploading?
This question has an accepted answers - jump to answer
Answers
Looks like you can use
ajax
as an object and specify the URL for upload.Kevin
But i'm not sure how the syntax for that looks like.
i can't write directly in this preupload function "ajax.url=". I need to assign it to a parameter that goes into the function (e, fieldName,file,data).
I tried "e.ajax.url=": "Cannot set property 'url' of undefined"...since e is the ajax object already i guess.
But then "e.url=" should work, but it doesn't - it's not defined. (I tried first a console.log (e.url) to check if this is existing with the default assigned url - but it's not)
I feel i'm close to this...but how would be the exact syntax that i need to use?
Ohh - i should have read your linked post to the end...
I tried the steps that are listed lower on that page - now it's working!
Thank you so much! Took me ages to figure this out