views:

46

answers:

2

The problem is I am using get_info() to make a ajax call to Result.lasso and paste the response 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

A: 

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.

noah
@noah Thank you for the reply It worked by using $('#test').html(response) What is the reason for why it's not working for higher versions of jquery while it's working for older version?
I honestly don't know why it works for that old version of jQuery. innerHTML is not reliable for executing scripts across browsers, so I'd be surprised if the old version worked reliably.
noah
A: 

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

Tim Taplin