Jump to content

Ajax response not received


learningprobs

Recommended Posts

Hello,

 

I am having a bit of an annoying problem.

 

 

I am trying to get an error message returned as json from my php script, at the moment all I am getting is this error in the console:

parsererror SyntaxError: Unexpected token < in JSON at position 10(…)

I would have believed(based on what I researched) that this error was due to the dataType not being set properly, but it is.

 

 

Here is page 1 ajax code:

                        var video_title_php = document.getElementById('videoName').value;
                        var video_description_php = document.getElementById('videoDescription').value;
                        var video_category_php = document.getElementById('videoCategoryId').value;
                        var video_uid = "<?php echo $id; ?>";


                        $.ajax({
                        url: 'index.php?page=producer_save_video.php',
                        dataType: "json",
                        data: {
                            videoidurl:videoId,
                            video_title:video_title_php,
                            video_description:video_description_php,
                            video_category:video_category_php,
                            video_uid:video_uid
                        },
                        type: 'POST',
        success: function (response) {


          $("#php_results").html(response);
        },
        error: function(jqXHR, textStatus, errorThrown) {
           console.log(textStatus, errorThrown);
        }
                        })

And this is the simple json text I am trying to output on the other page:

<?phpecho json_encode(array('error' => 'Well done! Your video has been uploaded!'));
?>

Any idea please?

 

 

Thanks.

 

 
Link to comment
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.