How to unescape with jquery?

Asked

Viewed 39 times

0

I’m putting together a page with ajax, she has a registration modal

I have a form that is in the file novo.php and I need to do his include inside the modal.

The modal is created the moment the user clicks on the sign-up button:

var inc = '<div class="modal"><p class="close_modal"></p><?="<?php include(\"View/Professor/novo.php\");?>"?></div>';
$(document).ready(function(){
     $('#cadastro').click(function(){
         $('article').prepend('<div class="dark"></div>');
         $('article').prepend(inc);
     });
});

The prepend() puts php code inside the modal as I want, but jquery escapes php

When opening the console I realize that jquery wrote commented php:

<div class="modal">
   <p class"close_modal"></p>
   <!--<?php include("View/Professor/novo.php"); ?>-->
</div>

You can write php command inside Jquery without escaping them?

  • That string of var inc has twice the PHP opening tag <?... I think that’s the problem.

  • @Sergio the first opening tag is unique to writing, indicating that everything within it will be written on the page. The second tag is inside a string and will not be executed, I mean, it will be executed when written inside the modal, but jquery is commenting on it

  • I already solved the problem using the load() command but I would still like to get a resolution for this problem

  • But jQuery does not interpret PHP... everything that is PHP and not converted on the server will look like text in the browser. The browser does not read PHP.

  • @Sergio visibly jquery is escaping PHP, commented the excerpt even in HTML format

  • What do you mean "PHP is escaping"?

  • @Sergio used the incorrect term, 'escape strings' is a different process than the one I described. Within my jquery script I put a php command to write another php command inside the page, the goal was to make a include from another file, but jquery itself commented on the php code snippet, a visible security directive

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.