0

I am doing an AJAX request to be injected into div. it will supposedly include a JavaScript code at the end that will execute a function in the main page. I have tried the following but aint working. uploudInfo() is the function's name.

<script language="javascript" type="text/javascript">
     window.top.window.uploudInfo();
</script>

update

I included the following to be get once ajaxing but ain't working.
I'm using this ajax request TINY.box.fill('ajax.html',1,0,1) from this page http://www.scriptiny.com/2011/03/javascript-modal-windows/ but we can assume I'm not using any external codes to solve my issue just a simple ajax request like in this page http://www.w3schools.com/php/php_ajax_php.asp

<input value="uploudInfo();" id="but" onclick="uploudInfo()" type="hidden" />
<script type="text/javascript">      
  var e = document.getElementById('but').value;
  eval(e);
</script>
Sami Al-Subhi
  • 4,406
  • 9
  • 39
  • 66

2 Answers2

0

Try the JQuery .html(), it worked for me.

By design, any jQuery constructor or method that accepts an HTML string — jQuery(), .append(), .after(), etc. — can potentially execute code. This can occur by injection of script tags or use of HTML attributes that execute code (for example, ). Do not use these methods to insert strings obtained from untrusted sources such as URL query parameters, cookies, or form inputs. Doing so can introduce cross-site-scripting (XSS) vulnerabilities. Remove or escape any user input before adding content to the document.

Ref:

MHosafy
  • 176
  • 3
  • 12
0

if you are using jQuery:

$.ajax({
    url: "someurl.htm",
    dataType: "html",
    success: function(data){
        $('#thediv').html(data);
    }
});

Post your ajax code if you want more specific help.

ruffrey
  • 6,018
  • 3
  • 23
  • 19