0

I am getting error "JSON.parse: unexpected character" while entering in Video title and trying to submit form.I am unable to Submit form. Please suggest.

Firebug is showing error in jquery.js file line no. 541

parseJSON: function( data ) {
// Attempt to parse using the native JSON parser first
if ( window.JSON && window.JSON.parse ) {
**return window.JSON.parse( data );**  ---> Here (Line 541)
}
if ( data === null ) {
return data;
} 

@using (Html.BeginForm("SaveTrainerVideo", "Trainer", FormMethod.Post, new { @enctype = "multipart/form-data", @id = "Form_VideoGallery_Management" }))

    <span class="TrainerLabel">Upload Video<span class="MandatoryStar">*</span></span>
    <div style="position: relative; clear: both;">
        <input id="TrainerVideo" type="file" name="TrainerVideo" style="max-width: 91%" class="fileUploader" data-val="true" required="required" data-val-required="Please select video file for uploading." size="24px;" />

    </div>
    <div class="field-validation-error" id="showValid" style="display: none;">Please select video file for uploading.</div>
    <div id="progress" style="width: 60%; margin-top: 1%;">
        <div class="bar" style="width: 0%;"></div>
    </div>            

    <span class="TrainerLabel">Video Title<span class="MandatoryStar">*</span></span>
    @Html.TextBoxFor(m => m.VideoTitle, new { @class = "FitsomEditor", @style = "width:58%;" })
    <div class="field-validation-error" id="validTitle" style="display: none;">Please enter video title.</div>

    <div class="large-12 columns">
        <input id="btnSave" type="submit" class="button FitsomButton" value="Upload" onclick="return SetSaveValues()" />
    </div>
}


function SetSaveValues() {


    var File = document.getElementById('HasFile').value;
    var Title = document.getElementById('VideoTitle').value;

    if (Title != "" && File != "") {
        $("#showValid").hide();
        $("#validTitle").hide();
        return true;
    }
    else {
        if (File == null || File == '') {
            $("#showValid").show();
        }
        else {
            $("#showValid").hide();
        }
        if (Title == "") {
            $("#validTitle").show();
        }
        else {
            $("#validTitle").hide();
    }
        return false;
    }

}

1 Answer 1

3

try this

parseJSON: function( data ) {
   // Attempt to parse using the native JSON parser first
  if ( window.JSON && window.JSON.parse ) {
  return jQuery.parseJSON(data);
 }
if ( data === null ) {
   return data;
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.