Jump to content

Recommended Posts

I have a script that uploads images. It uses PHP to process the images and determine if there is an error or not. I have it set up so that $error= the error message, but if $error="", $result says "Successfully Uploaded"

 

Here is the problem:

When file is uploaded, either a success icon or a failed icon appear next to the message. Here is how it is currently set up:

 


    fileComplete: function(file, response) {

        this.options.processResponse || this

        var json = $H(JSON.decode(response, true));

        if (json.get('result') == 'success') {

            file.element.addClass('file-success');

            file.info.set('html', json.get('size'));

        } else {

            file.element.addClass('file-failed');

            file.info.set('html', json.get('error') || response);

        }

    },

 

I got rid of the JSON part on the PHP side, because it was too complicated and unnecessary for what I need it to do. I am not very familiar with javascript, but I want it to give the class of either "file-failed" or "file-success" depending on what $error is. If $error is nothing, it needs to add the class "file-success", otherwise it needs to add "file-failed".

 

Does this make sense to anyone? I hope so.

Link to comment
https://forums.phpfreaks.com/topic/196057-help-with-javascript/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.