Syntax for AJAX (json format)
-
Supposedly this is a very simple problem to solve with a few lines of code, but I don’t have the knowledge to get it done.
I have a video upload button, and upon successfully uploading without any page refreshing, I receive a callback object named ‘uploadSuccess’ which contains several values including ‘hashed_id’. I need to grab that value (hashed_id) and insert it within a PUT (or POST, not sure) request like so:
PUT https://api.wistia.com/v1/(insert hashed_id here)/.json?name=New-Name
This will result in changing the name of the file to “New-Name”. How do I do this with AJAX? Using a POST method? I would so deeply appreciate it if you could provide an actual example with the proper syntax and structure! In desperate need of help here, as I am far outside my circle of competence.The following shows the general structure of the current upload script, which works perfectly BUT does not change the file name as I need it do.
<div id="wistia-upload-widget" style="width: 250px; height: 40px;"></div> <script src="https://static.wistia.com/javascripts/upload_widget.js"></script> <script> var cback = { 'uploadSuccess': function(jsonFile) { $("#form-submit").show(); //not important } }; var widget1 = new wistia.UploadWidget({ divId: 'wistia-upload-widget', //not important publicProjectId: 'blahblahprojectid', //not important callbacks: cback, buttonText: 'Upload Lesson Video' }); //not important </script>
Maybe needs something like this in there? I’ve tried putting it under the ‘uploadSuccess’ code to no avail. Tried .post instead also:
$.put("https://api.wistia.com/v1/medias/" + jsonFile.hashed_id + ".json?name=New-Name");
- The topic ‘Syntax for AJAX (json format)’ is closed to new replies.