Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bashy's avatar

It's probably because you're trying to read it as a string and not a JSON object?

alert(JSON.stringify(json));
theUnforgiven's avatar

All im trying to do is push the changes via ajax to this method:

public function updateProductOption()
    {

        if(Request::ajax()) {
            $thisID = Input::get('id');
            $size = Input::get('size');
            $colour = Input::get('colour');
            $stock = Input::get('stock');

            DB::table('product_options')
                ->where('id', $thisID)
                ->update(array('size' => $size, 'colour' => $colour, 'stock' => $stock));
        }

    }

to update a db table. But still getting this bloody error - Resource interpreted as Document but transferred with MIME type application/json

theUnforgiven's avatar
theUnforgiven
OP
Best Answer
Level 51

This:

 $(document).ready(function(){

        $('.update').click(function(e) {
        e.preventDefault();

            var url             = "http://clothing.app/updateProductOption";
            var $post             = {};
            $post.id            = $(this).attr('rel');
            $post.size            = $('#size_' + $post.id).val();
            $post.colour        = $('#colour_' + $post.id).val();
            $post.stock            = $('#stock_' + $post.id).val();

            $.ajax({
            type: "POST",
            url: url,
            data: $post,
            cache: false,
            success: function(data){
               return data;
            }
            });
            return false;
        });
     });

Now works YIPEEEEE!!!!!!1

2 likes
bashy's avatar

Yeah there's no need to return the response, that's the only reason you were getting the error :)

1 like
diafol's avatar

I know this is an old thread, so apologies, but I ran into a similar issue. I had a simple ajax calculator that serialised the data on the form and round-tripped a response to a textbox. I kept getting an Internal Error 500. The reason for this as far as I could tell was that it was on an UPDATE form with a PUT method. When I inspected the serialized data, sure enough there was a "_method" field with "PUT" as its value. I then sent then data as field:value pairs instead (without the _method field) - and it worked fine. Hope it helps somebody.

Previous

Please or to participate in this conversation.