简体   繁体   English

jquery Post在我的页面的这一部分不起作用

[英]jquery Post not working just in this part of my page

I am trying to show an image by ajax-jquery. 我试图通过ajax-jquery显示图像。

this is part of my html: 这是我的HTML的一部分:

<div id="searchFormResult1"></div>

<form action="#" method="post" id="searchForm" onSubmit="return false;">
    <input type="text" maxlength="10" id="searchid" name="searchid" class="searchstu" />
    <input type="submit" value="0" id="searchsubb" class="hidd searchsub" />
    <a href="#" id="link-2" onClick="sear(); return false;"></a>
</form>

the div tag is a place for returning php. div标签是一个返回php的地方。

my jquery is like this and I put jquery inside the html page: 我的jquery是这样的,我把jquery放在html页面中:

$("#searchsubb").click(function(){
$.post("parts/search.php", {searchid:$("#searchid").val()}, function(data){
    $("#searchFormResult1").html(data).slideDown();
});
});

also I have a php page that returning an image html tag: 我还有一个返回图像html标签的php页面:

something like this: 这样的事情:

print "<img src='' /> and other thing"; 

but my returning value is not receiving. 但我的回归价值没有收到。

I dont get any error in my browser and I believe the problem is not from my php. 我的浏览器中没有任何错误,我相信问题不是来自我的PHP。

I receive this error in chrome some times . 我有时会在chrome中收到此错误。

Error in event handler for 'undefined': INDEX_SIZE_ERR: DOM Exception 1 Error: Index or size was negative, or greater than the allowed value.
at J (chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:14:142)
at null.<anonymous> (chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:17:184)
at chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:1:182
at miscellaneous_bindings:286:9
at chrome.Event.dispatchToListener (event_bindings:387:21)
at chrome.Event.dispatch_ (event_bindings:373:27)
at chrome.Event.dispatch (event_bindings:393:17)
at Object.chromeHidden.Port.dispatchOnMessage (miscellaneous_bindings:253:22) 

I believe your submitting the form at the same time you fire the ajax request. 我相信你在发出ajax请求的同时提交表单。

Add return false to prevent the form submission. 添加return false以阻止表单提交。

$("#searchsubb").click(function(){
$.post("parts/search.php", {searchid:$("#searchid").val()}, function(data){
    $("#searchFormResult1").html(data).slideDown();
});
return false;
});

问题必须在PHP中,否则你会从ajax获得响应,来自$ .post触发器的第三个参数当ajax从parts / search.php获得响应时,尝试查看firebug中的响应标记,如果你没有一个是空或没有回应

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM