0
I have a code Ajax that takes the data from a simple message field and sends it to my database without the page being updated, only the problem is that everything works perfectly only by computer, when access by mobile phone the sending simply does not happen.
HTML:
<form method="post" action="../controller/SendChatMessage.class.php?act=open_chat&id_unique_talk=<?=$get_id_unique_talk?>&to_id=<?=$get_id_para?>" id="send_message_chat" ajax="true">
<div class="col-sm-10">
<div class="message-area">
<textarea placeholder="Message" rows="10" name="message" id="txt_message"></textarea>
</div>
</div>
<button style="height:28px;margin-top:-39px !important;" type="submit" class="btn btn-primary pull-right"> <i class="fa fa-send"></i></button>
</form>
Javascript:
<script type="text/javascript">
$(document).ready(function(e) {
$("form[ajax=true]").submit(function(e) {
e.preventDefault();
var form_data = $(this).serialize();
var form_url = $(this).attr("action");
var form_method = $(this).attr("method").toUpperCase();
$("#loading").show();
$.ajax({
url: form_url,
type: form_method,
data: form_data,
cache: false,
success: function(returnhtml){
$("#result").html(returnhtml);
$("#loading").hide();
document.getElementById('txt_message').value='';
}
});
});
});
</script>
I wonder if someone could help me?
So, I tried also with the data-ajax="true" only that it didn’t work even so on mobile, only on pc, as for the version of jquery and the version of my android is WW_15.0410.1804.61_0, I don’t know if this is what you are asking
– William De Paula
This loading there wasn’t even supposed to be there, it’s a message field of a chat so it doesn’t have to appear
– William De Paula
Ué, it is because on the computer it works, only on the mobile that does not
– William De Paula
Strange. Here it worked on both iOS and Android.
– Sam
Tries putting a
error:
and aalert
to see if it shows anything.– Sam