Home javascript UNEXPECTED END OF INPUT on pure JS. All brackets checked. I do...

UNEXPECTED END OF INPUT on pure JS. All brackets checked. I do not use JSON

Author

Date

Category

I can not understand what I missed. I want to execute AJAX by passing the parameter 3 in the PHP file when you click on the link. Before starting the function, the console displays UNCAUGHT SYNTAXERROR: UNEXPECTED END OF INPUT . Since I use MVC, the error knocks on the first line HTML file.

JavaScript code:

var dns = 'http: //fmbteka.local/';
   FUNCTION PAGINATIONAJAX (PAGE, MEDIA, SEARCHTEXT) {
    var uri = 'search /' + media + '/' + page + '/';
    var data = "search_text =" + searchText;
    var ajax = new xmlhttprequest ();
      ajax.open ("POST", DNS + URI, FALSE);
      ajax.setRequestheader ('Content-Type', 'Application / X-WWW-FORM-URLENCODED');
      ajax.send (DATA);
    var Products = Document.QuerySelector (". Products");
      Products.innerhtml = ajax.Response;
   }

php:

if (ISSET ($ searchText)) {
  $ Page1Right = "Paginationajax (". ($ Page + 1). ", '". $ Media. "', '". $ searchText. "' ')' & gt;". ($ Page + 1). "& Lt; / a & gt;";
}

All variables in the PHP file have a string type (string)

The variable $ Page1right is transmitted to the controller that inserts it into the view.

watched similar questions on the forums, all the same problem was the same – did not closed the bracket in jQuery, or the incorrect JSON pars. I do not use JSON and jQuery, so I do not understand what a mistake is made.


Answer 1, Authority 100%

Try to replace quotes in OnClick

if (ISSET ($ searchText)) {
  $ Page1Right = "& lt; A onClick = \" Paginationajax (". ($ Page + 1).", '". $ Media."', '"$ searchText."' ') \ "& gt;". ($ Page + 1). "& lt; / a & gt;";
}

Answer 2, Authority 50%

Look in the browser to the onClick attribute, and everything will become clear.


Answer 3, Authority 50%

Thank you, the first answer helped me. There was a problem in quotes

That’s what happened:

if (ISSET ($ searchText)) {
  $ Pathstr = "'. $ PATH."' '";
  $ searchTextStr = "'". $ searchText. "' '";
  $ Page1Right = '& lt; a onclick = "Paginationajax ('. $ Pathstr. ','. $ searchTextR. ')" STYLE = "CURSOR: POINTER" & GT; '. ($ Page + 1).' & lt; / a & gt; ';
}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions