I am using ajax to send a request where I save the id of the post in the url:
$.ajax({
...
url: "/api/request?id=" + id,
...
});
From what I have read, jQuery mobile uses the url for to load "pages" and for history purposes. Is there any way to bypass this? I have googled but have not found something that works for me.
Thanks!
(It works fine without importing the jQuery mobile library)
UPDATE
39 function getSavings(){
40
41 id = window.location.hash.split("/")[1];
42 console.debug(id);
43
44 var cols = [];
45 $("#history-table thead tr th").each(function(index, el){
46 cols.push($(el).attr('data-col'));
47 });
48
49 $("#history-table tbody").html("")
50 $("#history-table tbody").hide();
51 $("#amount").hide();
52 $.get({
53 type: "GET",
54 url: "api/savings?id=" + id,
55 error: function(xhr, settings, exceptions){
56 alert("could not get item");
57 },
58 success: function(data){
59 $("#item-name").html(`${data.Savings.Name}`);
60 for(let r of data.Savings){
61 var amount = r.Amount;
62 r.Amount = formatSavings(amount);
63 $("#amount").html(`
64 <div>${r.Amount}<span class="sek">sek</span></div>
65 `).fadeIn();
66
67 $("#item-crumb").html(`
68 <div>${r.Name}</div>
69 `).fadeIn();
70
71 }
72
73 for(let r of data.History){
74 var date = new Date(r.Datee).toLocaleDateString();
75 var time = new Date(r.Datee).toLocaleTimeString();
76 r.Datee = `${date} <span class="badge">${time}</span>`;
77 var tr = `<tr>`;
78 for(let c of cols){
79 if(c === "Amount" || c === "UpdatedAmount"){
80 var amount = r[c];
81 r[c]= formatSavings(amount);
82 }
83 tr += `<td>${r[c]}</td>`
84 }
85 tr += `</tr>`
86 $("#history-table tbody").append(tr).fadeIn();
87 }
88 }
89 });
90 $("#main-content").fadeIn();
91 }
error The error I get is: "404 not found"