Buddy, I would do it this way to facilitate the visualization of things in your code.
printf('fnc_eglise_ajaxGet("ajax/deletaPessoaVinculo.php?%s");', http_build_query(array(
'd' => $vinculo->DAT_INICI_VINCU,
'p' => 'PV',
'c' => $vinculo->COD_TIPOX_VINCU
)));
Although some criticize the use of sprintf
and printf
, I prefer to have something that is more organized, and easy to maintain and understand.
The http_build_query
will transform the array
php in querystring data.
Then he would turn it:
array('nome' => 'Wallace Maxters', 'profissao' => 'Programador PHP')
For that reason:
nome=Wallace+Maxters&profissao=Programador+PHP
See the code working on IDEONE
The result of my expression would result in the following string in PHP:
'fnc_eglise_ajaxGet("ajax/deletaPessoaVinculo.php?d=1&p=PV&c=alguma+coisa");'
PHP and JAVASCRIPT
According to the wish of the author of the question, I elaborated how the method mentioned above would be used together with the javascript desired by the same.
Would look like this:
$('#btnSalvaDelete').click(function () {
<?php
printf('fnc_eglise_ajaxGet("ajax/deletaPessoaVinculo.php?%s");',
http_build_query(array(
'd' => $vinculo-> DAT_INICI_VINCU,
'p' => 'PV',
'c' => $vinculo-> COD_TIPOX_VINCU,
)
));
?>
});
Probably the value of
<?php echo eglise_dataDeDMAParaAMD($vinculo->DAT_INICI_VINCU); ?>
,<?php echo $w_COD_IDENT_PESSO; ?>
or<?php echo $vinculo->COD_TIPOX_VINCU; ?>
has a'
that is "closing" the string. Take a look at the source code of the page in the browser, you will have more information about the problem.– carlosfigueira
The string was not closed, it may be a problem in the function or before/after that code.
– rray
If you’re mixing php with javascript, I’ll ask you to add the php tag to your question.
– Wallace Maxters
An important tip: in addition to mixing code, you are passing data to the url. Consider using functions such as
http_build_query
andurlencode
php.– Wallace Maxters