W3C validator: “Element head is missing a required instance of child element title” - w3c-validation

For http://www.filmiclub.com/, I am getting this error in the W3C validator:
Element head is missing a required instance of child element title
But when I copy the HTML and do validation with "Validate by direct input", the HTML is 100% error free and there is no validation error.
Do you know why PHP generated HTML with this error?

Choose the "Show source" option and click Revalidate, you'll see the cause. your PHP script is crashing when receiving a request from the validator, so then PHP sends out its own error message response instead of your website.
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: HTTP_ACCEPT</p>
<p>Filename: helpers/common_helper.php</p>
<p>Line Number: 7328</p>
Apparently the W3C's validator sends a HTTP request that does not have the Accept: header, but your PHP code expects the HTTP_ACCEPT header to be present and fails because it is absent.
Change your PHP code to detect the presence (or lack of) Accept header, like so:
if( isset( $_SERVER['HTTP_ACCEPT'] ) ) {
// code here
}

Related

How can html text be partially validated in Cypress?

I would like to validate or assert the text inside the div element of the following html has the correct email id
The html snippet is as follows:
<div _ngcontent-mpt-c200="" class="welcome-msg">
Hi, Welcome to our blog, dummyuser#test.com (
<a _ngcontent-mpt-c200="" class="pointer">not Dummy User?
</a>)
</div>
My cypress assertion is:
cy.get('.welcome-msg').invoke('text').should('include.text', 'dummyuser#test.com')
I get this error:
Timed out retrying after 4000ms: You attempted to make a chai-jQuery assertion on an object that is neither a DOM object or a jQuery object.
The chai-jQuery assertion you used was:
text
The invalid subject you asserted on was:
Hi, Welcome to our blog, dummyuser#test.com (not Dummy User?)
To use chai-jQuery assertions your subject must be valid.
I also tried using:
cy.get('.welcome-msg').should('contain.text', 'dummyuser#test.com')
and this:
cy.get('.welcome-msg').invoke('html.text').then(userInfoText => {
userInfoText.should('contain.text', 'dummyuser#test.com')
})
Has anyone got an idea on how to make this assertion work?
In your first attempt you invoked the text() to get the text of the jQuery element followed by an assertion that essentially does the same thing before asserting the text.
You can do either of two things with your first attempt.
cy.get('.welcome-msg').should('include.text', 'dummyuser#test.com')
or
cy.get('.welcome-msg').invoke('text').should('include', 'dummyuser#test.com')

Backend form validation callback approach | vuex store | vuejs

My question is about handling "database validation errors" to the user using a Vuex store. (see image below)
Any advice on how to handle this ?
Then display my errors specified and "positioned" by field.
Something like this:
<label>Title</label>
<input type="text">
<p v-if="errors.title">{{errors.title}}</p>
My first thought was to pass the 'db errors' received by the 'vuex store action' too a 'store state attribute', and use a computed property with a "store getter" in the vuejs component to display the error, but this just doesn't feel right to me.
I use this json model for getting data from the server: {status: 0, result: {}, error: {}}.
In that case you can check the status attribute, for the success of the rest api call. So depends on the status, you can handle either the error, or the result variable.
On the server side, if any error / exception caught, you can send back to the client (specifically), in the error variable.
In your case, e.g.: you caught a db error on a server side, you define status for that (e.g.) 430, you send back the message with the error and the status code, that way you can handle nicely the problem.
I hope it helps! :)

500 error even request render HTML code

Using ajax to get HTML content from GSP template .
$.get(url,{word:$('#search').val()},fnback)
The browser Console raises 500 error .
However , we get the expected response , but in browser not in callback .
Known that this kind of error appears only in production environment .
This question is related to this ticket
The error is caused either by Grails or by your application, you will need to determine why; it certainly seems to be happening relatively late in the pipeline since you are getting the correct HTML back (I assume you aren't explicitly rendering a 500 status code in your code by accident).
As for the response you are getting back, it is ignored due to the 500 status. The $.get function accepts a callback which is only invoked on successful requests. If you put debug lines into your fnback function you will see it is never called. If you were to replace the $.get with an equivalent $.ajax call and provide an error callback, that function would get the HTML you are seeing returned in the browser's dev tools.
Based on #Gregor Petrin answer :
$.get(myurl,{word:word},function(d){
$('div#resp').html(d)
})
has been replaced by :
$.ajax({url:myurl,data:{word:word}}).always(function(d,status){
if(status !=='success'){
d=d.responseText;
}
$('div#resp').html(d);
});

parsererror status 'ok'. error code 200

When i submit my JqGrid edit form, i am getting 'parsererror status 'ok'. error code 200' . can some one help me in getting to know why this error occurs, though i am getting response from server.
below are my codes
beforeShowForm: function(form){
$('#tr_ArticleID',form).hide();
$('#tr_ContractNo',form).hide();
},
url: "/JqGridDemo/prfArticle.do"
Also how should i get the response status (success / failed ) from server in a message box.
And how this submit button in jqGrid works??
i am using json here. many thanks.
Caution Wahab, You are parsing the HTTP Status Code. Doubtlessly, parsing OK will lead to an error. I don't know jqgrid but you need to fetch the response. Not the header information.

Using jqgrid, what is the best way to return errors from server side validation when using inline editing?

I am using jqgrid and using the inline editing mode and can't figure out how to return errors back to the client from server side validation rules
I use fluent validation on my serverside to validate before persisting to a database. This works great except I don't see how to return errors when editing in inline mode. If I don't persist the values to the databse, the client still shows the value which should be rejected.
What is the recommended way to return an error after someone commits an inline edit so you will get some popup on the client side showing the error and it will stay in edit state ?
NOTE: this image below is in response to Oleg's comment and answer below
The recommend way is to use any HTTP error code in the response on the submitting of wrong data and to return the error description in the body of the response. If you need some more specific action like displaying another dialog with the error information, setting of focus on a field, marking some fields with CSS class 'ui-state-error' or something like that you should use errorfunc callback function.
If restoreAfterError is false the inline editing will be continued.
UPDATED: I mention in comments that the server should produce the error message as the response. In case of ASP.NET MVC the default message is HTML text which you posted as the first picture. If you use HandleJsonExceptionAttribute which I described in my old answer the error message will be serialized as JSON, but it contains additional information which you don't need to display (like the StackTrace). So you should use errorfunc parameter of editRow or saveRow to decode the server response. You can either use decodeErrorMessage from the already referenced answer or use the $.parseJSON function directly:
errorfunc: function(rowid, res) {
var errorText = $.parseJSON(res.responseText).Message;
$.jgrid.info_dialog($.jgrid.errors.errcap,
'<div class="ui-state-error">' + errorText + '</div>',
$.jgrid.edit.bClose,
{buttonalign: 'right'});
}

Resources