添加项目并停留在当前页面-php,ajax,jquery

时间:2018-07-20 12:51:07

标签: php jquery ajax

我正在使用Google翻译,因此可能会发生错误。

我的问题:添加项目并停留在当前页面

我尝试使用下面链接中的建议,但未成功:-(

Add Item and stay in current page

脚本代码:

                PrincipalContext principalContext =
                    new PrincipalContext(ContextType.Domain, LDAPDomain, LDAPContainer,
                        LDAPAdmin, LDAPPassword);

                GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, "groupName");

                if (group == null)
                {
                    GroupPrincipal groupPrincipal = new GroupPrincipal(principalContext);
                    groupPrincipal.Name = "groupName";
                    groupPrincipal.SamAccountName = "samAccountName";
                    groupPrincipal.UserPrincipalName = "userPrincipleName";
                    groupPrincipal.GroupScope = GroupScope.Global;
                    groupPrincipal.Description = "groupNameDescription";
                    groupPrincipal.DisplayName = "groupNameDisplayName";
                    groupPrincipal.Save();
                }

我已经重写了代码并将其添加到下面:

            GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, "groupName");
            UserPrincipal user = UserPrincipal.FindByIdentity(principalContext, "userName");

            bool isUserAdded = false;


            if (user != null & group != null)
            {
                if (user.IsMemberOf(group))
                {
                    //Do Code
                }
                else
                {
                    group.Members.Add(user);
                    group.Save();
                    isUserAdded = user.IsMemberOf(group);
                }
            }

            if (isUserAdded)
            {
                //Do Code
            }

但是仍然无法正常工作,单击按钮后,产品已添加,但我们不在同一页面上,而是转到购物篮。

我将不胜感激

亚当

3 个答案:

答案 0 :(得分:0)

您可以使用GOOG.f <- structure(list(IS = structure(list(`12/31/2017` = c(110855000, 45583000, 65272000, 16625000, 19765000, NA, NA, 81973000, 28882000, -1689000, 28882000, -109000, 27193000, 14531000, NA, 12662000, NA, NA, NA, NA, 12662000, NA, 12662000), `12/31/2016` = c(90272000, 35138000, 55134000, 13948000, 17470000, NA, NA, 66556000, 23716000, 434000, 23716000, -124000, 24150000, 4672000, NA, 19478000, NA, NA, NA, NA, 19478000, NA, 19478000), `12/31/2015` = c(74989000, 28164000, 46825000, 12282000, 15183000, NA, NA, 55629000, 19360000, 291000, 19360000, -104000, 19651000, 3303000, NA, 16348000, NA, NA, NA, NA, 16348000, NA, 16348000), `12/31/2014` = c(66001000, 25313000, 40688000, 9832000, 13982000, NA, NA, 49127000, 16874000, 385000, 16874000, -101000, 17259000, 3639000, NA, 13620000, 516000, NA, NA, NA, 14136000, NA, 14136000)), .Names = c("12/31/2017", "12/31/2016", "12/31/2015", "12/31/2014"), row.names = c("Total Revenue", "Cost of Revenue", "Gross Profit", "Research Development", "Selling General and Administrative", "Non Recurring", "Others", "Total Operating Expenses", "Operating Income or Loss", "Total Other Income/Expenses Net", "Earnings Before Interest and Taxes", "Interest Expense", "Income Before Tax", "Income Tax Expense", "Minority Interest", "Net Income From Continuing Ops", "Discontinued Operations", "Extraordinary Items", "Effect Of Accounting Changes", "Other Items", "Net Income", "Preferred Stock And Other Adjustments", "Net Income Applicable To Common Shares" ), class = "data.frame"), BS = structure(list(`12/31/2017` = c(10715000, 91156000, 18705000, 749000, 2983000, 124308000, 7813000, 42383000, 16747000, 2692000, NA, 3352000, 680000, 197295000, 3137000, 3969000, 10651000, 24183000, 3943000, 16641000, NA, NA, NA, 44793000, NA, NA, NA, 40247000, 113247000, -992000, NA, -992000, 152502000, 133063000), `12/31/2016` = c(12918000, 73415000, 15632000, 268000, 3175000, 105408000, 5878000, 34234000, 16468000, 3307000, NA, 2202000, 383000, 167497000, 2041000, 3935000, 5851000, 16756000, 3935000, 7770000, NA, NA, NA, 28461000, NA, NA, NA, 36307000, 105131000, -2402000, NA, -2402000, 139036000, 119261000), `12/31/2015` = c(15409000, 56517000, 13459000, 491000, 1590000, 90114000, 5183000, 29016000, 15869000, 3847000, NA, 3432000, 251000, 147461000, 1931000, 7648000, 4327000, 19310000, 1995000, 5825000, NA, NA, NA, 27130000, NA, NA, NA, 32982000, 89223000, -1874000, NA, -1874000, 120331000, 100615000), `12/31/2014` = c(16585000, 46048000, 9974000, NA, 2637000, 78656000, 3079000, 23883000, 15599000, 4607000, NA, 3363000, 176000, 129187000, 1715000, 8015000, 2803000, 16779000, 2992000, 5320000, NA, NA, NA, 25327000, NA, NA, NA, 28767000, 75066000, 27000, NA, 27000, 103860000, 83654000)), .Names = c("12/31/2017", "12/31/2016", "12/31/2015", "12/31/2014"), row.names = c("Cash And Cash Equivalents", "Short Term Investments", "Net Receivables", "Inventory", "Other Current Assets", "Total Current Assets", "Long Term Investments", "Property Plant and Equipment", "Goodwill", "Intangible Assets", "Accumulated Amortization", "Other Assets", "Deferred Long Term Asset Charges", "Total Assets", "Accounts Payable", "Short/Current Long Term Debt", "Other Current Liabilities", "Total Current Liabilities", "Long Term Debt", "Other Liabilities", "Deferred Long Term Liability Charges", "Minority Interest", "Negative Goodwill", "Total Liabilities", "Misc. Stocks Options Warrants", "Redeemable Preferred Stock", "Preferred Stock", "Common Stock", "Retained Earnings", "Treasury Stock", "Capital Surplus", "Other Stockholder Equity", "Total Stockholder Equity", "Net Tangible Assets"), class = "data.frame"), CF = structure(list(`12/31/2017` = c(12662000, 6899000, 8284000, -3768000, 1121000, NA, 3682000, 37091000, -13184000, -19448000, 1419000, -31401000, NA, NA, -86000, -3366000, -8298000, 405000, -2203000), `12/31/2016` = c(19478000, 6100000, 7158000, -2578000, 333000, NA, 2420000, 36036000, -10212000, -18229000, -1978000, -31165000, NA, NA, -1335000, -3304000, -8332000, -170000, -3631000), `12/31/2015` = c(16348000, 5024000, 5609000, -2094000, 246000, NA, 1618000, 26572000, -9950000, -13635000, 75000, -23711000, NA, NA, -23000, -2422000, -4225000, -434000, -1798000 ), `12/31/2014` = c(14136000, 4601000, 3615000, -1641000, 261000, NA, 1461000, 23024000, -11014000, -6222000, 628000, -21055000, NA, NA, -18000, -2069000, -2087000, -433000, -551000 )), .Names = c("12/31/2017", "12/31/2016", "12/31/2015", "12/31/2014"), row.names = c("Net Income", "Depreciation", "Adjustments To Net Income", "Changes In Accounts Receivables", "Changes In Liabilities", "Changes In Inventories", "Changes In Other Operating Activities", "Total Cash Flow From Operating Activities", "Capital Expenditures", "Investments", "Other Cash flows from Investing Activities", "Total Cash Flows From Investing Activities", "Dividends Paid", "Sale Purchase of Stock", "Net Borrowings", "Other Cash Flows from Financing Activities", "Total Cash Flows From Financing Activities", "Effect Of Exchange Rate Changes", "Change In Cash and Cash Equivalents"), class = "data.frame")), .Names = c("IS", "BS", "CF")) 而不是返回false;

android {
    compileSdkVersion 27

    sourceSets.main.jni.srcDirs = []

    task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
        commandLine "$ndkDir/ndk-build",
        'NDK_PROJECT_PATH=build/intermediates/ndk',
        'NDK_LIBS_OUT=src/main/jniLibs',
        'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
        'NDK_APPLICATION_MK=src/main/jni/Application.mk'
    }

    tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn ndkBuild
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation project(':OpenCVLibrary244')
        implementation 'com.android.support:support-v4:27.0.2'
    }

编辑1:

您可以再做一件事。而不是将输入类型设置为e.preventDefault()。就像我注意到您正在手动制作JSON一样,将其保留为<script type="text/javascript"> $('#addBasket .submit').click(function(e) { e.preventDefault(); var keyValues = { iProductAdd : $(this).parent().find('input[name="iProductAdd"]').val(), iQuantity : $(this).parent().find('input[name="iQuantity"]').val() }; $.post('<?php echo $oPage->aPages[$config['basket_page']]['sLinkName']; ?>', keyValues, function(rsp) { // make your php script return some xml or json that gives the result // rsp will be the response }); });

所以您的输入提交可以是这样的

submit

答案 1 :(得分:0)

你可以试试吗?

$('#addBasket .submit').click(function(event) {
 event.preventDefault();
var keyValues = {
    iProductAdd : $(this).parent().find('input[name="iProductAdd"]').val(),
    iQuantity : $(this).parent().find('input[name="iQuantity"]').val()
};
$.post('<?php echo $oPage->aPages[$config['basket_page']]['sLinkName']; ?>', keyValues, function(rsp) {
    // make your php script return some xml or json that gives the result
    // rsp will be the response
});
return false; // so the page doesn't POST
});

答案 2 :(得分:0)

未将事件侦听器添加到按钮,因为当脚本标签位于表单上方时,按钮不存在

将脚本标记放在表单后面,或将代码包装在“就绪” 调用中

$(function(){
  $('#addBasket .submit').click(function() {
  ...
})