Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery ajax post not working on iPhone and Android
    text
    copied!<p>I'm building a web application targeting mobile devices (specifically iPhone and Android). I'm building it using ASP.NET MVC and JQuery. On one page I have a cascading dropdown. I've hooked up a function on the change event for the first dropdown and that does an AJAX call and uses the JSON response to populate the second dropdown. This all works fine on my desktop, but does not work from an iPhone or Android phone. The second dropdown is not populated. I placed an "alert" in the change function and it verified that the event is being triggered. I then placed the "alert" in the callback function for the AJAX call and it didn't get executed, so either the AJAX call is not hitting the server, or the response is not being received by the phone.</p> <p>The jQuery code is:</p> <pre><code> $(function () { $("#ProgramId").change(function () { var programId = $("#ProgramId").attr("value"); alert("Change event triggered"); // &lt;- test only, does get executed when client is a phone bowser var termId = $("#TermId").attr("value"); $.post("/DealerHome/Terms", { "ProgramId": programId }, function (data) { alert("Ajax response received"); // &lt;- test only, does NOT get executed when client is a phone bowser $("#TermId").children().remove(); $("#TermId").append('&lt;option value="0"&gt;--select--&lt;/option&gt;'); $.each(data, function () { if (termId == this.Value) { $("#TermId").append('&lt;option value="' + this.Value + '" selected &gt;' + this.Text + '&lt;/option&gt;'); } else { $("#TermId").append('&lt;option value="' + this.Value + '" &gt;' + this.Text + '&lt;/option&gt;'); } }); }); }); }); </code></pre> <p>I've turned on JavaScript Console on the iPhone, but it doesn't show any errors. Being new to developing for mobile devices, I'm not sure how I should debug this. On the desktop, I would just use Fiddler to see what's happening on the wire. Any help is much appreciatec.</p> <p>Cheers</p> <p>Craig</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload