0

I'm loading a page (which has HTML and jQuery in it) by using fetch, but it doesn't response to my jQuery codes.

  fetch('/get_insurance.bc', {
       method: 'POST',
       body: 'inscountry=[##cms.form.inscountry##]&fdate=[##cms.form.fdate##]-05&tdate=[##cms.form.tdate##]&birthdate='+brt+'&userid=[##userid.userid.userid##]'})
       .then(response => response.text())  
       .then(html => {
            document.getElementById('ins-list-resize').innerHTML = html;
  })
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • You mean you're loading script blocks via AJAX? They won't get executed, for security reasons. – ADyson Sep 22 '19 at 20:46
  • Im loading a page wich containing html and jquery codes by using fetch , in other page. first i use response.text() but by this case my jquery codes dosent work – basisfly designer Sep 23 '19 at 05:52
  • You've used response.html() above, not response.text(). But anyway like I said, if what you're loading contains JavaScript/jQuery code, that code won't be executed by the browser, for security reasons. You need to find another way to achieve whatever you're trying to do. See https://stackoverflow.com/a/4620099/5947043 for example – ADyson Sep 23 '19 at 06:22
  • I tried this way (first add a extranal js file and push all my jquery codes in it and call it in my second page which is loading . and then add this js file in my first page ) but it dosent work! – basisfly designer Sep 23 '19 at 07:31
  • 1
    "doesn't work" isn't a useful error message or problem statement. No-one can help you based on that. If you tried another way and also had a problem then please add full details of that to your question. Thanks. – ADyson Sep 23 '19 at 07:38
  • No, you didn't fully explain. Imagine you were a mechanic, and I ask you to fix my car. You ask what the problem is. I tell you "it doesn't work", and also I don't show you the car. Can you fix it? Or do you need to ask for more information? It's the same here...except I'm the mechanic trying to fix your car. If you don't give specific details about the problem then you can't expect anyone to understand the issue. Sorry if you don't like that but that's a universal truth. – ADyson Sep 23 '19 at 08:08
  • You have mentioned two different ways you tried to achieve your requirement. But you've only properly explained one of those ways, or shown us any context about it. You also haven't explained whether you tried the method I gave in the link above. – ADyson Sep 23 '19 at 08:10

0 Answers0