开发者

Problem loading scripts from Ajax Response

开发者 https://www.devze.com 2022-12-21 02:19 出处:网络
The problem is I am using get_info() to make a ajax call to Result.lasso and paste the respo开发者_运维知识库nse in div with id \'test\'.I am unable to use the sendForm() function from the page where

The problem is I am using get_info() to make a ajax call to Result.lasso and paste the respo开发者_运维知识库nse in div with id 'test'.I am unable to use the sendForm() function from the page where i am calling the get_info().

I have also tried using different versions of jQuery 1.1.1.3 is working fine.But i am facing the problem while using higher versions of jquery.

The error with higher versions is as follows

missing } in XML expression
[Break on this error] alert('hi');\n
test.lasso (line 3)
sendForm is not defined
[Break on this error] sendForm();  

get_info() function definition

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<SCRIPT>
function get_info()
{
    $.ajax({url: "Result.lasso", context: document.body, success: function(response){
    document.getElementById('test').innerHTML = response ;},dataType:"script"});
}
</SCRIPT>

The code in Result.lasso is as follows

[Content_Type: 'text/html; charset=UTF-8']
<script type="text/javascript">
    function sendForm()
    {   
        alert('hi');
    }
</script>   
[Date]
 form name= "abc" method = "get" action = "abcd.lasso">
    input type ="text" name = "element1"/>
    input type = "button" value="Click" onClick = "javascript: sendForm();"/>
</form>

Please help me out in resolving this problem

Thanks, Rajesh Konatham


Your formatting is pretty messed up, so I may misunderstand, but it sounds like you're loading HTML with script tags that you want executed?

Try $('#test').html(response); instead of document.getElementById('test').innerHTML = response;. Also, it should be dataType:"html" not script.


you may also be having some wierd issues with browser translation because of the missing opening < on your form tag on Result.lasso

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号