有没有一种方法来调用php与$ .get以外的事件? [英] Is there a way to call php with an event other than $.get?

查看:138
本文介绍了有没有一种方法来调用php与$ .get以外的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:找到下面我的问题的解决方案。看到这里 - > IE必须关闭事件与jQuery工作

EDIT : Found the solution to my problem below. See it here -> IE must close for event with jQuery to work

我一直在问,试图弄清楚一个。如果有任何其他方法可以在PHP中通过事件执行mySql查询,而不是$ .get。

I've been asking around, trying to figure this one out. If there are any other way to do a mySql query in PHP by an event .. other than $.get.

我之前曾经发布过另一个问题,以防万一有人可以帮助 - >
$。在IE中无法工作

I've previously posted this one other problem just in case somebody could help out -> $.get not working in IE

现在我试图找到一种方式围绕我以前发布的问题,如果$ .get不会在IE中发生,那么我必须有另一种方式。也许不是用jQuery

Now I'm trying to find a way around the problem I previously posted cause if $.get is not going to happen in IE for me then there has to be another way with this. Maybe not with jQuery

推荐答案

也许你可以尝试这个longhand语法(如$ .get是$ .ajax的缩写别名)

Perhaps you could try the longhand syntax (as $.get is a shorthand alias of $.ajax)

function getbillinfo(tbl) {
    $.ajax({
        type: "POST",
        url: "getbillno.php",
        data: "tbl=" + tbl,
        success: function(bill){
            $("#billno").val(bill); });
        }
    });
}

请参阅 http://api.jquery.com/jQuery.ajax/

编辑: / strong>关于你的IE的问题,可能有几个原因

with regard to your problems with IE, there could be a couple of reasons

可能性一个


IE缓存Ajax调用的结果到同一个资源,即使你
告诉它不在你的HTTP头。所以如果你一次又一次地要求
getbillinof.php?tbl =表,IE会使
请求一次,然后再停止这个请求,只需返回
的结果的第一个请求。为了避免这种情况,您可以调用getbillinof.php?tbl = table& random_string_here

IE caches the results of Ajax calls to the same resource even if you tell it not to in your HTTP headers. So if you make a request to getbillinof.php?tbl=table over and over again, IE will make the request once and then stop making it in the future and simply return the result of the first request. To circumvent this you can call getbillinof.php?tbl=table&random_string_here

在ajax()选项中也可能设置cache:false,并查看isModified选项。

It may also be worth setting cache: false in the ajax() options and having a look into the isModified option.

可能性两个


竞赛条件导致IE渲染操作在
之前运行,任何数据都被返回。然而,不太可能,因为success()
函数只有在接收到数据后才能运行。
种族条件变得更有可能,如果你正在做一些像

A Race Condition is causing the IE render action to run before any data was returned. This however is unlikely as the success() function is only supposed to run once the data has been received. A race condition becomes far more likely if you're doing something like



function getbillinfo(tbl) {
    $.ajax({
        type: "POST",
        url: "getbillno.php",
        data: "tbl=" + tbl,
        success: function(bill){
            var mydata = bill;
        }
    });

    $("#billno").val(mydata);
}

这篇关于有没有一种方法来调用php与$ .get以外的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆