Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5989677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:08:09+00:00 2026-05-22T23:08:09+00:00

I have a problem with the following code, which doesn’t want to work in

  • 0

I have a problem with the following code, which doesn’t want to work in Chrome and Safari:

function updateBasket(data) {
if (data != '') {
    $.each(data, function(k, v) {
        if (jQuery.inArray(k, data.remove) == -1 && $('.' + k).length > 0) {
            $('.' + k).html(v);
        }
    });
}
}

$('.add_to_basket').live('click', function() {
    var button = $(this);
    var classes = $(this).attr("class");
    var identity = $(this).attr("rel").split('_');
    var url = '/basket/action/add/type/' + identity[0] + '/id/' + identity[1];
    $.ajax({
        type: 'POST',
        url: url, 
        data: ({ cls : classes }),
        dataType: 'json',
        success: function(data) {
            if (!data.error) {
                updateBasket(data);
                button.replaceWith(data.button);
            }   
        }       
    });
    return false;
});

The .add_to_basket trigger only works with the first click – after that it doesn’t do anything.
It works fine with Firefox and IEs, but for some reason Chrome and Safari doesn’t seem to like it.

Here’s the json response which comes after first click:

{
    "error": false,
    "items": {
        "27": {
            "price": "120.00",
            "qty": 1,
            "discount": 0,
            "vat": 0,
            "price_vat": 120
        }
    },
    "bundles": [],
    "no_of_items": 1,
    "sub_total": "£120.00",
    "vat_total": "£0.00",
    "total": "£120.00",
    "remove": ["remove", "error", "button", "items", "basket"],
    "button": "<a href=\"#\" class=\"button button_red add_to_basket\" rel=\"item_27\">Remove from the basket<\/a>"
}

and the one which comes after second one (returning to the initial state):

{
    "error": false,
    "items": [],
    "bundles": [],
    "no_of_items": 0,
    "sub_total": "&pound;0.00",
    "vat_total": "&pound;0.00",
    "total": "&pound;0.00",
    "remove": ["remove", "error", "button", "items", "basket"],
    "button": "<a href=\"#\" class=\"button button_blue add_to_basket\" rel=\"item_27\">Add to the basket<\/a>"
}

Any idea what I’m doing wrong here?

To make it even difficult – this is only happening with Chrome and Safari on Mac OSX 10.5 (Leopard) – but doesn’t on Snow Leopard – using the same versions of browsers (Chrome 11.0.696.71)

Just an update – I’ve done a few tests and it appears to be a problem with SESSIONS. It doesn’t allow me to log in either – meaning session is not created when using Chrome or Safari on Mac OS X 10.5.

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:08:10+00:00Added an answer on May 22, 2026 at 11:08 pm

    Ok – I’ve figured out what was causing problems:

    if (!isset($_SESSION)) {
         session_start();
    }
    

    which should simply be:

    session_start();
    

    as it checks on its own whether the session is set.

    Thanks for participating everyone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the following code: for(i = 0;(i - 1)< n;i++)
The following code demonstrates a weird problem I have in a Turbo C++ Explorer
I have the following problem in my Data Structures and Problem Solving using Java
I have the following problem. If I query values with a keyfigure which is
I have a problem with some JNI code. I'm getting the following error printed
I have the following MyType::Is_Inst () function which is throwing an invalid memory access
I have the following problem: I have an HTML textbox ( <input type=text> )
I have the following problem using subversion: I'm currently working on the trunk of
I have the following problem using template instantiation [*]. file foo.h class Foo {
I have the following problem: I open the dialog, open the SIP keyboard to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.