Intercooler JS not sending form data correctly on Safari





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I am developing a social media-type web application, and so far everything has been working fine on Chrome and Firefox. I recently discovered a bug on Safari (both iOS and macOS) where form data is not correctly being sent when I send an AJAX request using intercooler JS.



The issue was found first when I realized that Safari was not allowing friend requests to be accepted when people respond from their notifications area. Here is the relevant HTML for when people accept/deny a friend request from their notifications



<form method="post" ic-post-to="{% url 'respond-request' item.sender.pk %}">
{% csrf_token %}
<button name="accept" type="submit">Accept</button>
<button name="decline" type="submit">Decline</button>
</form>


In my Django View, I do two two things whenever someone responds to a friend request:




  1. Remove the notification/friend request entirely

  2. Add the users as friends if and only if accept is in request.POST


This is the relevant code



# Remove notification
notification = Notification.objects.get(receiver=request.user, sender=userProfile, action="friend_request_received")
notification.delete()

# Remove the request
request.user.friend_requests_received.remove(userProfile)

# If yes, then add to friends and remove from request
if 'accept' in request.POST:
request.user.friends.add(userProfile)


This is working as intended on Chrome and Firefox. When someone clicks accept on the above HTML, the users become friends. When they click decline, then the request is removed and they do not become friends.



The strange thing is that if the above HTML is used on Safari, the request is removed but the users do not become friends. I have printed request.POST in Django and can confirm the POST data is being sent as I expect from Chrome, but not Safari. Safari simply does not include accept, or any form data at all, in the AJAX request sent via intercooler, making the if statement in my above code never fire.



Is this simply a bug with Intercooler? I saw on various posts people talking about using jQuery to modify the AJAX call in certain ways, but I could not find anything related to using Intercooler. Is there a way to achieve what I want on Safari using only Intercooler and AJAX?










share|improve this question


















  • 1





    Out of curiosity, have you tried putting an explicit value attribute on the button: <button name="accept" type="submit" value="accept">Accept</button>

    – Will Keeling
    Nov 16 '18 at 14:48











  • Yes, that was something I forgot to mention I tried. Didn't help :(

    – Luke Bordonaro
    Nov 16 '18 at 14:55


















1















I am developing a social media-type web application, and so far everything has been working fine on Chrome and Firefox. I recently discovered a bug on Safari (both iOS and macOS) where form data is not correctly being sent when I send an AJAX request using intercooler JS.



The issue was found first when I realized that Safari was not allowing friend requests to be accepted when people respond from their notifications area. Here is the relevant HTML for when people accept/deny a friend request from their notifications



<form method="post" ic-post-to="{% url 'respond-request' item.sender.pk %}">
{% csrf_token %}
<button name="accept" type="submit">Accept</button>
<button name="decline" type="submit">Decline</button>
</form>


In my Django View, I do two two things whenever someone responds to a friend request:




  1. Remove the notification/friend request entirely

  2. Add the users as friends if and only if accept is in request.POST


This is the relevant code



# Remove notification
notification = Notification.objects.get(receiver=request.user, sender=userProfile, action="friend_request_received")
notification.delete()

# Remove the request
request.user.friend_requests_received.remove(userProfile)

# If yes, then add to friends and remove from request
if 'accept' in request.POST:
request.user.friends.add(userProfile)


This is working as intended on Chrome and Firefox. When someone clicks accept on the above HTML, the users become friends. When they click decline, then the request is removed and they do not become friends.



The strange thing is that if the above HTML is used on Safari, the request is removed but the users do not become friends. I have printed request.POST in Django and can confirm the POST data is being sent as I expect from Chrome, but not Safari. Safari simply does not include accept, or any form data at all, in the AJAX request sent via intercooler, making the if statement in my above code never fire.



Is this simply a bug with Intercooler? I saw on various posts people talking about using jQuery to modify the AJAX call in certain ways, but I could not find anything related to using Intercooler. Is there a way to achieve what I want on Safari using only Intercooler and AJAX?










share|improve this question


















  • 1





    Out of curiosity, have you tried putting an explicit value attribute on the button: <button name="accept" type="submit" value="accept">Accept</button>

    – Will Keeling
    Nov 16 '18 at 14:48











  • Yes, that was something I forgot to mention I tried. Didn't help :(

    – Luke Bordonaro
    Nov 16 '18 at 14:55














1












1








1








I am developing a social media-type web application, and so far everything has been working fine on Chrome and Firefox. I recently discovered a bug on Safari (both iOS and macOS) where form data is not correctly being sent when I send an AJAX request using intercooler JS.



The issue was found first when I realized that Safari was not allowing friend requests to be accepted when people respond from their notifications area. Here is the relevant HTML for when people accept/deny a friend request from their notifications



<form method="post" ic-post-to="{% url 'respond-request' item.sender.pk %}">
{% csrf_token %}
<button name="accept" type="submit">Accept</button>
<button name="decline" type="submit">Decline</button>
</form>


In my Django View, I do two two things whenever someone responds to a friend request:




  1. Remove the notification/friend request entirely

  2. Add the users as friends if and only if accept is in request.POST


This is the relevant code



# Remove notification
notification = Notification.objects.get(receiver=request.user, sender=userProfile, action="friend_request_received")
notification.delete()

# Remove the request
request.user.friend_requests_received.remove(userProfile)

# If yes, then add to friends and remove from request
if 'accept' in request.POST:
request.user.friends.add(userProfile)


This is working as intended on Chrome and Firefox. When someone clicks accept on the above HTML, the users become friends. When they click decline, then the request is removed and they do not become friends.



The strange thing is that if the above HTML is used on Safari, the request is removed but the users do not become friends. I have printed request.POST in Django and can confirm the POST data is being sent as I expect from Chrome, but not Safari. Safari simply does not include accept, or any form data at all, in the AJAX request sent via intercooler, making the if statement in my above code never fire.



Is this simply a bug with Intercooler? I saw on various posts people talking about using jQuery to modify the AJAX call in certain ways, but I could not find anything related to using Intercooler. Is there a way to achieve what I want on Safari using only Intercooler and AJAX?










share|improve this question














I am developing a social media-type web application, and so far everything has been working fine on Chrome and Firefox. I recently discovered a bug on Safari (both iOS and macOS) where form data is not correctly being sent when I send an AJAX request using intercooler JS.



The issue was found first when I realized that Safari was not allowing friend requests to be accepted when people respond from their notifications area. Here is the relevant HTML for when people accept/deny a friend request from their notifications



<form method="post" ic-post-to="{% url 'respond-request' item.sender.pk %}">
{% csrf_token %}
<button name="accept" type="submit">Accept</button>
<button name="decline" type="submit">Decline</button>
</form>


In my Django View, I do two two things whenever someone responds to a friend request:




  1. Remove the notification/friend request entirely

  2. Add the users as friends if and only if accept is in request.POST


This is the relevant code



# Remove notification
notification = Notification.objects.get(receiver=request.user, sender=userProfile, action="friend_request_received")
notification.delete()

# Remove the request
request.user.friend_requests_received.remove(userProfile)

# If yes, then add to friends and remove from request
if 'accept' in request.POST:
request.user.friends.add(userProfile)


This is working as intended on Chrome and Firefox. When someone clicks accept on the above HTML, the users become friends. When they click decline, then the request is removed and they do not become friends.



The strange thing is that if the above HTML is used on Safari, the request is removed but the users do not become friends. I have printed request.POST in Django and can confirm the POST data is being sent as I expect from Chrome, but not Safari. Safari simply does not include accept, or any form data at all, in the AJAX request sent via intercooler, making the if statement in my above code never fire.



Is this simply a bug with Intercooler? I saw on various posts people talking about using jQuery to modify the AJAX call in certain ways, but I could not find anything related to using Intercooler. Is there a way to achieve what I want on Safari using only Intercooler and AJAX?







javascript jquery ajax django safari






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 14:38









Luke BordonaroLuke Bordonaro

32529




32529








  • 1





    Out of curiosity, have you tried putting an explicit value attribute on the button: <button name="accept" type="submit" value="accept">Accept</button>

    – Will Keeling
    Nov 16 '18 at 14:48











  • Yes, that was something I forgot to mention I tried. Didn't help :(

    – Luke Bordonaro
    Nov 16 '18 at 14:55














  • 1





    Out of curiosity, have you tried putting an explicit value attribute on the button: <button name="accept" type="submit" value="accept">Accept</button>

    – Will Keeling
    Nov 16 '18 at 14:48











  • Yes, that was something I forgot to mention I tried. Didn't help :(

    – Luke Bordonaro
    Nov 16 '18 at 14:55








1




1





Out of curiosity, have you tried putting an explicit value attribute on the button: <button name="accept" type="submit" value="accept">Accept</button>

– Will Keeling
Nov 16 '18 at 14:48





Out of curiosity, have you tried putting an explicit value attribute on the button: <button name="accept" type="submit" value="accept">Accept</button>

– Will Keeling
Nov 16 '18 at 14:48













Yes, that was something I forgot to mention I tried. Didn't help :(

– Luke Bordonaro
Nov 16 '18 at 14:55





Yes, that was something I forgot to mention I tried. Didn't help :(

– Luke Bordonaro
Nov 16 '18 at 14:55












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339930%2fintercooler-js-not-sending-form-data-correctly-on-safari%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339930%2fintercooler-js-not-sending-form-data-correctly-on-safari%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine