in Education by
I am trying to pass a dataString to to an ajax call using JQuery. In the call, I construct the get parameters and then send them to the php page on the receiving end. The trouble is that the data string has ampersands in them and the HTML strict validator is chocking on it. Here is the code: $(document).ready(function(){ $("input#email").focus(); $('#login_submit').submit(function(){ var username = $('input#email').val(); var password = $('input#password').val(); var remember = $('input#remember').attr("checked"); var dataString = "email="+username+"&password="+password+"&remember="+remember; $.post('login.php', dataString, function(data) { if (data == 'Login Succeeded.') { location.reload(true); } else { $("input#email").focus(); $("#login_msg").html(data).effect("pulsate", {times: 2}, 1000); } }); return false; }); }); and here is an example of the validator message: cannot generate system identifier for general entity "password". var dataString = "email="+username+"&password="+password+"&remember="+rememb… (in the validator the "p" after the first ampersand is marked red indicating the point of the failure). JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Try putting your javascript inside a CDATA block like this: <![CDATA[ // content of your Javascript goes here ]]> which should make it pass validation. To be extra safe you can add Javascript comments around the CDATA tags to hide them from older browsers who don't understand the CDATA tag: /* <![CDATA[ */ // content of your Javascript goes here /* ]]> */

Related questions

0 votes
    You are converting your HTML file into XHTML Strict. Which code snippet will validate without errors? asked Mar 10, 2023 in Technology by JackTerrance
0 votes
    I'm working with ASP.NET 3.5. I have a list box that users must add items to (I've written ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I have a Date object. How do I render the title portion of the following snippet? A couple days ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 15, 2022 in Education by JackTerrance
0 votes
    Specifically I have a PHP command-line script that at a certain point requires input from the user. I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Specifically I have a PHP command-line script that at a certain point requires input from the user. I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 18, 2022 in Education by JackTerrance
0 votes
    Specifically I have a PHP command-line script that at a certain point requires input from the user. I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    On destruction of a restful resource, I want to guarantee a few things before I allow a destroy operation ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    On destruction of a restful resource, I want to guarantee a few things before I allow a destroy operation ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    On destruction of a restful resource, I want to guarantee a few things before I allow a destroy operation ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    Which is the function in JavaScript that will print the current page in JavaScript? (a) print() (b ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    I'm porting functionality from an Objective-C iPhone app to a Javascript iPhone app (Appcelerator Titanium). ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    In C# when I am done entering the fields of a snippet, I can hit Enter to get to the next line. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    In C# when I am done entering the fields of a snippet, I can hit Enter to get to the next line. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    How do you focus a particular part of the HTML page in JavaScript? (a) hover() (b) focus() (c ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    What will be done if more than one page requires a file of JavaScript code? (a) Downloads that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
...