tags:

views:

109

answers:

2

Hi I was trying to mobilise my website and I ran into an issue with Jquery. When I was trying to perform a jquery call (.$ajax) it was not getting rendered. This is the part of the code

 var returnData = '';
                $.ajax({url: './indexSubmit.php',
                    async: false,
                    dataType: 'json',
                    data:{flag:'vehicleInfo',
                        vehicleId:xVehicleId},
                        success: function(data,textStatus){
                        if(textStatus != 'success'){
                            alert('Error: '+ textStatus);
                            return;
                        }
                        returnData = data;

I am not sure, but I guess I need to install jquery in the browser. If yes, can I automatically download and install jquery in the browser using some javascript?

A: 

If I get it right, what you need is to include the jquery library so you can use it on your page. Then you need a <script> tag on your html page. The most straightforward way:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

Inside the <head> ... </head> block on your html page. Of course, inside the src attribute you can specify a path inside your own webserver where the jquery.js file is.

Fernando Figueiredo
I'd use 1.4.2 ... if you're just getting started, no reason in beginning with an old version.
Nick Craver
+1  A: 

Your object is malformed, you are missing a closing brace, paren and semi-colon:

         var returnData = '';
            $.ajax({url: './indexSubmit.php',
                async: false,
                dataType: 'json',
                data:{
                    flag:'vehicleInfo',
                    vehicleId:xVehicleId
                },
                success: function(data,textStatus){
                    if(textStatus != 'success'){
                        alert('Error: '+ textStatus);
                        return;
                    }
                    returnData = data;
                }); // <- this was missing
Dan Heberden
Sorry, I have it in my code, but it is not working and yes it works on non mobile browser.
Radhika