1

I have html/kendo ui mobile as follows:

<li><a data-action="initContactView" data-click="initContactView">Contacts</a></li>

then javascript:

function initContactView() {
    alert('before');
    var txtSearch = document.getElementById('searchTextField');
    $.ajax({
        type: "GET",
        data: =  "txtSearch='" + txtSearch +"'",
        contentType: "application/json; charset=utf-8",
        url: "http://xot-wsdl.compx.net/mobile.asmx/ContactGet",
        dataType: "json",
        success: successContact,
    });
    alert('after');
}

the function successContact is just putting it all in list view.
My problem is when I take out all the code in JavaScript function the alert works fine, as soon as I put all the other code back, nothing happens when I trigger the button.

What the JavaScript code should do is to connect to my web service and retrieve data.

Any help?

3
  • 3
    That would be the syntax errors halting your code execution, such as data: = 'string' etc. which is not valid Commented Apr 3, 2014 at 10:16
  • ok cool thanx, is there any way I can debug javascript not using alerts? Commented Apr 3, 2014 at 10:21
  • Yes, using the console ! Commented Apr 3, 2014 at 10:24

2 Answers 2

2
  1. You have a syntax problem on "data: ="
  2. I see you use jQuery, why don't use $("#searchTextField") for find the field?
  3. txtSearch with getElementById will return a DOM element, non the value of the field, use this istead:

    var txtSearch = $("#searchTextField").val();

EDIT: For debugging you can use FireBug with Mozilla or any other developers tools available in al major browsers.

EDIT 2: In the ajax URL i see a complete URL, please be sure that the url is in the same domain of your web server or you will get a permission denied error.

Sign up to request clarification or add additional context in comments.

Comments

0

If you are using Google Chrome you can press Ctrl+Shift+I - Also firefox. Then you can debug your javascript errors by looking for the erros in debug.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.