When I add mobile jquery another library stops its work. - php

When I add js/jquery.mobile-1.4.5.min.js library all above jquery are not working only this jquery.mobile-1.4.5.min.js jquery working and navigation stop its work. So how to short out this jquery list to work all in proper way.
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="js/stickUp.min.js" type="text/javascript"></script>
<script src="js/colorbox/jquery.colorbox-min.js" type="text/javascript"> </script>
<!-- templatemo 395 urbanic -->
<script src="js/templatemo_script.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).ready(function () {
$(".anchor_img").click(function (e) {
//$('#overlay_form, #overlay-back').fadeIn(500);
var targetPopup = $(this).attr('id');
$("#hidden_id").attr('value',targetPopup);
$.ajax({
type: "POST",
url: "popup.php?id="+targetPopup,
dataType : 'json',
data: $('#myform').serialize(), // serializes the form's elements.
success: function(data)
{
//$(".overlay_form").fadeIn(1000);
//$(".overlay_form").html(data);
//$.each(data.employees, function(key, value){
//$(".overlay_form").load(data);
//$('.overlay_form').html(data);
//console.log(data);
$(".overlay_form").fadeIn();
$(".cover").fadeTo(500, 0.8);
$("#id>img").attr("src",data.fullpath);
$("#popup_img_id").attr("value",data.id);
console.log(data.fullpath);
//$("#cboxOverlay").show();
//});
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
//close popup
$(".close").click(function () {
$(".overlay_form").fadeOut();
$(".cover").fadeOut();
});
$('body').click(function(e) {
if (!$(e.target).closest('.overlay_form').length){
$(".overlay_form").fadeOut();
$(".cover").fadeOut();
}
});
});
//maintain the popup at center of the page when browser resized
//$(window).bind('resize', positionPopup);
</script>
<script>
$("#popup_submit").click(function (e) {
var pname = $("#popup_user_name").attr('value');
var pmobile = $("#popup_user_mobile").attr('value');
var pcomment = $("#popup_user_comment").attr('value');
if(pname == "")
{
alert("Plz Enter Your Name");
return false;
}
if(pmobile == "")
{
alert("Plz Enter Your Mobile");
return false;
}
if(pcomment == "")
{
alert("Plz Enter Your Comment");
return false;
}
$.ajax({
type: "POST",
url: "popup_msg.php",
dataType : 'json',
data: $('#myform_popup').serialize(), // serializes the form's elements.
success: function(data)
{
alert("Message Sent !");
$("#popup_user_name").val("");
$("#popup_user_mobile").val("");
$("#popup_user_comment").val("");
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
</script>
<script>
$("#popup_user_mobile").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
$("#user_mobile").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#contact_errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
</script>

It's impossible to say for sure what all conflicts you may be experiencing, but a likely problem is the fact you are including jQuery twice. I would suggest reworking your script includes so that you only pull in jQuery a single time. This may probably work, but it depends on your script version requirements:
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="js/stickUp.min.js" type="text/javascript"></script>
<script src="js/colorbox/jquery.colorbox-min.js" type="text/javascript"> </script>
<!-- templatemo 395 urbanic -->
<script src="js/templatemo_script.js" type="text/javascript"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
The only change I made was removing <script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>, which was inserted right before you included jQuery mobile, since you already included jQuery on the first line.

Related

Searching not working in ajax once textbox onblur event is called

I have the following code to search through AJAX. Now if I apply onblur event to the textbox (so that searching result disappears) and get back to the textbox again, searching facility is no more working. So the thing is, it might not be able to call onfocus event properly once onblur event is called. Any help would be appreciated.
<script type="text/javascript">
$(document).ready(function () {
$(".searchproductbrand").keyup(function () {
var kw = $(".searchproductbrand").val();
if (kw != '') {
$.ajax({
type: "POST",
url: "livesearch.php",
data: "kw=" + kw,
success: function (option) {
$("#livesearch").html(option);
document.getElementById("livesearch").style.border = "1px solid #A5ACB2";
}
});
} else {
$("#livesearch").html("");
document.getElementById("livesearch").style.border = "0px";
}
return false;
});
});
</script>
<script>
$(document).ready(function () {
$(".searchproductbrand").blur(function () {
document.getElementById("livesearch").style.display = "none";
})
});
</script>
Livesearch is the div where I print my search results.
You should provide your markup, or a jsfiddle but i'm almost sure that everything is working but on the onblur event you set the display rule of the 'livesearch' element to none, but you never set it back to block so you made it invisible and it stayed that way because you need to set it to block or whatever visibible display rule that you want, i created a jsfiddle example based on what you posted, i took the liberty to alter your code and removed the ajax part so you can focus on the real issue, i hope this solves your problem.
http://jsfiddle.net/kFj9u/1
jQuery(document).ready(function(){
var $liveSearch = $('#liveSearch');
$(".searchProductBrand").keyup(function(){
var keyWord = $(this).val();
if(keyWord != ''){
var msg = 'You searched for ' + keyWord;
$liveSearch.css('display','block').html(msg);
}else{
$liveSearch.html('').
css('border','none');
}
}).blur(function(){
$liveSearch.css('display','none');
})
});
Probably your livesearch is still hidden, try this:
<script type="text/javascript">
$(document).ready(function () {
$(".searchproductbrand").keyup(function () {
var kw = $(".searchproductbrand").val();
if (kw != '') {
$.ajax({
type: "POST",
url: "livesearch.php",
data: "kw=" + kw,
success: function (option) {
$("#livesearch").show(); // this is
$("#livesearch").html(option);
document.getElementById("livesearch").style.border = "1px solid #A5ACB2";
}
});
} else {
$("#livesearch").html("");
document.getElementById("livesearch").style.border = "0px";
}
return false;
});
});
</script>
<script>
$(document).ready(function () {
$(".searchproductbrand").blur(function () {
document.getElementById("livesearch").style.display = "none";
})
});
</script>

Sending map boundary via Jquery to google maps ui

I use this script to get the markers for Google Maps with JSON.
It is not working because I need to receive the boundary in the Json script like this:
$swLat=$_GET["swLat"];
$swLon=$_GET["swLon"];
$neLat=$_GET["neLat"];
$neLon=$_GET["neLon"];
That is where I need your help.
Google maps script
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="http://skiweather.eu/gmap3/js/jquery.ui.map.js"></script>
<script language="javascript" type="text/javascript">
var map = null;
map = new google.maps.Map(document.getElementById("map"));
var markers = new Array();
var bounds = map.getBounds();
var zoomLevel = map.getZoom();
$(function() {
demo.add(function() {
$('#map').gmap().bind('init', function() {
$.getJSON( 'http://skiweather.eu/gmap3/markers/index.php', {zoom: zoomLevel,
swLat: bounds.getSouthWest().lat(), swLon: bounds.getSouthWest().lng(),
neLat: bounds.getNorthEast().lat(), neLon: bounds.getNorthEast().lng()}, function(data) {
$.each( data.markers, function(i, marker) {
$('#map').gmap('addMarker', {
'position': new google.maps.LatLng(marker.latitude, marker.longitude),
'bounds': true
}).click(function() {
$('#map').gmap('openInfoWindow', { 'content': marker.content }, this);
});
});
});
});
}).load();
});
</script>
</head>
<body>
<div id="map"></div>
The jQuery/gmap-part of your code will not be executed at all.
Fixed code:
<script type="text/javascript">
$(function() {
$('#map').gmap().bind('init', function() {
var markers = new Array();
var bounds = $(this).gmap('get','map').getBounds();
var zoomLevel = $(this).gmap('get','map').getZoom();
$.getJSON( 'http://skiweather.eu/gmap3/markers/index.php', {zoom: zoomLevel,
swLat: bounds.getSouthWest().lat(), swLon: bounds.getSouthWest().lng(),
neLat: bounds.getNorthEast().lat(), neLon: bounds.getNorthEast().lng()}, function(data) {
$.each( data.markers, function(i, marker) {
$('#map').gmap('addMarker', {
'position': new google.maps.LatLng(marker.latitude, marker.longitude),
'bounds': true
}).click(function() {
$('#map').gmap('openInfoWindow', { 'content': marker.content }, this);
});
});
});
});
});
</script>
However, it's sending the data now, but it's still not working, because the server will not give any response(are you sure that there is a webservice that returns JSON-data?)

confusion about basic AJAX code

<script>
try {
function xmldo() {
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("para").innerHTML = xmlhttp.responseText;
}
}
var URL = "http:\\127.0.0.1\ajax.php";
xmlhttp.open("GET", URL, true);
xmlhttp.send();
}
} catch (err) {
document.write(err.message);
}
</script>
<p id="para">Hey message will change</p>
<br>
<button type="button" onclick="xmldo()">Click me</button>
This is my code webpage I want to change the content of #para.innerHTML by the respnse in my another php file ajax.php
<?php
$response="hey is text changed";
echo $response;
?>
I am using wamp so i placed my ajax.php in my www folder and set the location of file on server as 127.0.0.1/ajax.php [URL] but i on pressing the button the text at para placeholder is not getting changed.
I am new to AJAX so must be missing on some points. Plz help me with them.
Change the slashes in your URL.
You have: http:\\127.0.0.1\ajax.php but the correct way is: http://127.0.0.1/ajax.php
I would also suggest using jQuery to perform AJAX requests - it's much simpler and you write less code!
I've added an example below written in jQuery:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#button_id").click(function(){
$.ajax({
url: 'http://127.0.0.1/ajax.php',
cache: false,
type: 'GET',
dataType: 'HTML',
error: function (e){
console.log(e);
},
success: function (response){
$("#para").empty().append(response);
}
});
});
});
</script>
<p id="para">Hey message will change</p><br>
<button type="button" id="button_id">Click me</button>

Submit a form and reload data on same page

I got a left_column with a #form, when I sumbmit it should load the results on #content_div without refreshing the page.
Im using this:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script type="text/javascript">
$(function() {
$('#dateform').submit(function(evt) {
evt.preventDefault();
$.ajax({
url: "charts/client.php",
type: 'POST',
data: $(this).serialize(),
success: function(result) {
$('#content_div').html(result);
}
});
});
});
</script>
<div id="content_div">
Nothing seems to appear.
And firebug reports this:
ReferenceError: google is not defined
This charts/client.php is using google api, and yes i've declared it like this:
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
What am I doing wrong?
Thanks
use ajax form
<script>
// wait for the DOM to be loaded
$(document).ready(function()
{
// bind 'myForm' and provide a simple callback function
$("#tempForm").ajaxForm({
url:'../calling action or servlet',
type:'post',
beforeSend:function()
{
alert("perform action before making the ajax call like showing soinner image");
},
success:function(e){
alert("data is"+e);
alert("now do whatever you want with the data");
}
});
});
</script>
you can find the plugin here
It seems that the error you get is from the client.php, not from the actual jquery ajax script.
Probably you tried to call a google method before creating a new instance of the google object you used. I could help you out more if you post the client.php's code here.
For example, when i have worked with gmaps api:
trying to do:
geocoder.geocode( { 'address': target}, function(results, status) {...
before setting :
var geocoder = new google.maps.Geocoder();
will return "google is not defined";

Ajax call not being made in jQuery

I have this jQuery code that runs on form submit:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" >
$(function()
{
$("input[type=submit]").click(function()
{
var name = $("#problem_name").val();
var problem_blurb = $("#problem_blurb").val();
var dataString = 'problem_name='+ name + '&problem_blurb=' + problem_blurb;
if(name=='' || problem_blurb == '')
{
$('.success').fadeOut(200).hide();
$('.error').fadeOut(200).show();
}
else
{
$.ajax({
type: "POST",
url: "problems/add_problem.php",
data: dataString,
success: function()
{
$('.success').fadeIn(200).show();
$('.error').fadeOut(200).hide();
}
});
}
return false;
});
});
</script>
And in the directory named /problems/ I have a php file add_problem.php and that file simply has this so I can see in the logs that it is being called:
<?php
echo ".......in problem";
?>
But this never gets written to the logs. Is there something wrong with my ajax call? I know that the js gets to the ajax part fine because I had some alert statements there that I took out.
If the file that contains this javascript is not located in the same directory that contains problems/ you should change:
url: "problems/add_problem.php",
to
url: "/problems/add_problem.php",

Categories