Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 从Ajax响应加载脚本时出现问题_Jquery_Ajax_Post_Scripting - Fatal编程技术网

Jquery 从Ajax响应加载脚本时出现问题

Jquery 从Ajax响应加载脚本时出现问题,jquery,ajax,post,scripting,Jquery,Ajax,Post,Scripting,问题是我正在使用get_info对Result.lasso进行ajax调用,并将响应粘贴到id为“test”的div中。我无法从调用get_info的页面使用sendForm函数 我也尝试过使用不同版本的jQuery 1.1.1.3,但在使用更高版本的jQuery时,我遇到了这个问题 更高版本的错误如下 missing } in XML expression [Break on this error] alert('hi');\n test.lasso (line 3) sendForm is

问题是我正在使用get_info对Result.lasso进行ajax调用,并将响应粘贴到id为“test”的div中。我无法从调用get_info的页面使用sendForm函数

我也尝试过使用不同版本的jQuery 1.1.1.3,但在使用更高版本的jQuery时,我遇到了这个问题

更高版本的错误如下

missing } in XML expression
[Break on this error] alert('hi');\n
test.lasso (line 3)
sendForm is not defined
[Break on this error] sendForm();  
获取函数定义的信息

<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>
Result.lasso中的代码如下

[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>
请帮我解决这个问题

谢谢,
Rajesh Konatham

您的格式设置非常混乱,因此我可能会误解,但听起来您正在加载HTML,其中包含要执行的脚本标记


尝试$'test'.htmlresponse;而不是document.getElementById'test'.innerHTML=response;。而且它应该是数据类型:html而不是脚本。

由于结果的表单标记上缺少开头<,您可能在浏览器翻译方面遇到了一些棘手的问题。lasso

@noah感谢您使用$'test'对它的回复。htmlresponse为什么它在为更高版本的jquery工作时不工作旧版本?我真的不知道为什么它适用于旧版本的jQuery。innerHTML在跨浏览器执行脚本时不可靠,因此如果旧版本工作可靠,我会感到惊讶。