3
I’m trying to replace a certain value within a HTML parseado
, using the following function I can override values that are within inputs tags, css and etc:
$('input[value="/services/CouponTemplate.mvc/GetCoupon"]').attr('value', function(_, href){
return "https://meusite.com?url=https://siteremoto.com" + href;
});
Only now I need to replace an address inside the tag <script type="text/javascript">
.
It’s like this:
<script type="text/javascript">var inPlayPreferences={"MarketOrder":,"InPlayAppServiceName":"/services/InPlayApp.mvc/"};</script>
I need to replace the /services/InPlayApp.mvc/
, i can put PHP with str_replace
, but I wonder if you can do the same using jQuery.
I tried to repeat the procedure by changing the input
for script
but it didn’t work, I’m a beginner in the Javascript world.
There is something similar to str_replace
PHP in jQuery?
I think that should really be done on the server side. If you have to change on the client side it is option to simply give a new value to the variable?:
inPlayPreferences.InPlayAppServiceName = "/services/novoNome.mvc/";
– Sergio
I didn’t understand why. Couldn’t you just assign a new value to the array? inPlayPreferences["Inplayappservicename"] = "new value here..";
– Daniel Omine
The data of
InPlayAppServiceName
are automatically generated by the remote site, if I assign a new value to it, simply the script would stop working, because the code is large and contains instructions in base_64 that is generated on each page differently, just summarized the code to facilitate the explanation. Already the question of Sergio, I’m doing it right on the server side, but I was wondering if it could be done on the client side, just out of curiosity even.– Cassiano José